Go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
in := bufio.NewReader(os.Stdin)
var n, m, x int
fmt.Fscan(in, &n, &m, &x)
a, b := make([]int, n), 0
ib := make(map[int]int)
for i := 0; i < n; i++ {
fmt.Fscan(in, &a[i])
}
for i := 0; i < m; i++ {
fmt.Fscan(in, &b)
ib[b] = i
}
for i := 0; i < n; i++ {
complement := x - a[i]
if idx, ok := ib[complement]; ok {
fmt.Println(i, idx)
}
}
}
C++
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
int n, m, x;
scanf("%d %d %d", &n, &m, &x);
vector<int> a(n);
unordered_map<int, int> ib;
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
for (int i = 0; i < m; ++i) {
int b;
scanf("%d", &b);
ib[b] = i;
}
for (int i = 0; i < n; ++i) {
int complement = x - a[i];
if (ib.find(complement) != ib.end()) {
printf("%d %d\n", i, ib[complement]);
}
}
return 0;
}