编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#22301 #1119. Rhodoks的2-sum问题 Compile Error 0 0 ms 0 K C++ / 349 B lyg 2020-02-12 11:53:05
显示原始代码
#include <iostream>
using namespace std;
int main() {
    int n, K;
    cin >> n >> K;
    set<int> a;
    int fg = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        fg = a.count(K - x);
        if (fg != 0) {
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
        return 0;
    }
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:6:5: error: 'set' was not declared in this scope
     set<int> a;
     ^~~
/sandbox/1/a.cpp:6:5: note: 'std::set' is defined in header '<set>'; did you forget to '#include <set>'?
/sandbox/1/a.cpp:2:1:
+#include <set>
 using namespace std;
/sandbox/1/a.cpp:6:5:
     set<int> a;
     ^~~
/sandbox/1/a.cpp:6:9: error: expected primary-expression before 'int'
     set<int> a;
         ^~~
/sandbox/1/a.cpp:11:12: error: 'a' was not declared in this scope
         fg=a.count(K-x);
            ^