Task: | 3SUM |
Sender: | Niilo |
Submission time: | 2024-10-21 17:32:17 +0300 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:31:2: error: expected '}' at end of input 31 | } | ^ input/code.cpp:9:12: note: to match this '{' 9 | int main() { | ^
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5000; unordered_set<ll> S; int T[N]; int main() { ll n, x; cin >> n >> x; for (int i = 0; i < n; ++i) { int k; cin >> k; T[i] = k; S.insert(i); } for (int i = 0; i < n; ++i) { S.erase(T[i]); for (int j = 0; j < i; ++j) { ll k = x - T[i] - T[j]; if (S.count(k)) { int ind = i+1; while (T[ind] != k) ++ind; cout << i+1 << ' ' << j+1 << ' ' << ind+1 << '\n'; return 0; } } cout << "IMPOSSIBLE\n"; }