Submission #1113525

#TimeUsernameProblemLanguageResultExecution timeMemory
1113525dynam1cNaval battle (CEOI24_battle)C++17
0 / 100
916 ms7140 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<tuple<int, int, char, int>> ships(n); int ii = 0; for (auto& [x, y, c, i] : ships) cin >> x >> y >> c, i = ii++; sort(ships.begin(), ships.end(), [&](tuple<int, int, char, int> a, tuple<int, int, char, int> b) { auto [x1, y1, c1, i1] = a; auto [x2, y2, c2, i2] = b; return x1+y1 < x2+y2 || x1 < x2; }); int prev = 0; stack<int> st; vector<bool> sunk(n); for (auto& [x, y, c, i] : ships) { if (x+y != prev) st = stack<int>{}; prev = x+y; if (c == 'E') st.push(i); else if (!st.empty()) sunk[i] = true, sunk[st.top()] = true, st.pop(); } for (int i = 0; i < n; i++) if (!sunk[i]) cout << i+1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...