1 条题解
-
0
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { vector<ll> a; ll x; while (cin >> x && x != -1) a.push_back(x); map<ll, vector<int>> pos; for (int i = 0; i < (int)a.size(); i++) { pos[a[i]].push_back(i); } bool found = false; ll ans0 = 0, ans1 = 0, ans2 = 0; int best_second = INT_MAX, best_first = INT_MAX; for (auto &kv : pos) { ll v = kv.first; auto &p = kv.second; if ((int)p.size() < 2) continue; bool ok = true; for (int idx : p) { if (idx + 2 >= (int)a.size()) { ok = false; break; } } if (!ok) continue; ll b0 = a[p[0]], b1 = a[p[0] + 1], b2 = a[p[0] + 2]; for (int idx : p) { if (a[idx] != b0 || a[idx + 1] != b1 || a[idx + 2] != b2) { ok = false; break; } } if (!ok) continue; int first_pos = p[0]; int second_pos = p[1]; if (second_pos < best_second || (second_pos == best_second && first_pos < best_first)) { best_second = second_pos; best_first = first_pos; ans0 = b0; ans1 = b1; ans2 = b2; found = true; } } if (!found) { cout << "NONE\n"; } else { cout << ans0 << ' ' << ans1 << ' ' << ans2 << '\n'; } } return 0; }
- 1
信息
- ID
- 194
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 76
- 已通过
- 4
- 上传者