Submission #1220315

#TimeUsernameProblemLanguageResultExecution timeMemory
1220315KindaGoodGamesNaval battle (CEOI24_battle)C++20
20 / 100
3094 ms15332 KiB
#include<bits/stdc++.h> using namespace std; #define tiii tuple<int,int,char> #define pii pair<int,int> #define pci pair<char,int> tiii move(tiii t){ int x,y,d; tie(x,y,d) = t; if(d == 'N'){ y--; } if(d == 'E'){ x++; } if(d == 'S'){ y++; } if(d == 'W'){ x--; } tiii r = {x,y,d}; return r; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<tiii> arr(n); for(int i = 0; i < n; i++){ int x,y; char d; cin >> x >> y >> d; arr[i] = {x,y,d}; } map<pii, pci> pos; for(int i = 0; i < n; i++){ int x,y; char d; tie(x,y,d) = arr[i]; pos[{x,y}] = {d,i}; } vector<bool> sunk(n); for(int t = 0; t <= 100000; t++){ set<pii> bad; for(int i = 0; i < n; i++){ if(sunk[i]) continue; int x,y; char d; pos.erase({get<0>(arr[i]), get<1>(arr[i])}); tiii nxt = move(arr[i]); tie(x,y,d) = nxt; if(pos.count({x,y})){ sunk[i] = true; sunk[pos[{x,y}].second] = true; pos.erase({x,y}); bad.insert({x,y}); }else if(bad.count({x,y})){ sunk[i] = true; } else{ pos[{x,y}] = {d,i}; arr[i] = {x,y,d}; } } } for(auto u : pos){ cout << u.second.second+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...