Submission #1261688

#TimeUsernameProblemLanguageResultExecution timeMemory
1261688kikitop1ggNaval battle (CEOI24_battle)C++17
6 / 100
1228 ms1114112 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<ll> #define vvi vector<vector<ll>> #define vs vector<string> #define vc vector<char> #define vb vector<bool> #define vp vector<pair<ll, ll>> #define vpp vector<pair<ll, pair<ll, ll>>> #define pp pair<ll, ll> #define qi queue<ll> #define qp queue<pp> #define pqi priority_queue<ll> #define pqp priority_queue<pp> #define mi map<ll, ll> #define mpi map<pp, ll> #define mip map<ll, pp> #define mp map<pp, pp> #define mb map<ll, bool> #define si set<ll> #define sp set<pp> #define sc set<char> #define mod 1000000007 #define inf INT_MAX #define all(x) (x).begin(), (x).end() int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vp a(n); vc type(n); vector<pair<pp, ll>> north, south, east, west; for(int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second >> type[i]; if(type[i] == 'N') { north.push_back({a[i], i}); } else if(type[i] == 'S') { south.push_back({a[i], i}); } else if(type[i] == 'W') { west.push_back({a[i], i}); } else { east.push_back({a[i], i}); } } vector<pair<ll, pp>> deaths; for(int i = 0; i < east.size(); i++) { auto[x1, y1] = east[i].first; ll ind1 = east[i].second; for(int j = 0; j < south.size(); j++) { auto[x2, y2] = south[j].first; ll ind2 = south[j].second; if(x1 >= x2) continue; if(y1 <= y2) continue; ll time1 = abs(x1 - x2); ll time2 = abs(y1 - y2); if(time1 == time2) { deaths.push_back({time1, {ind1, ind2}}); } } for(int j = 0; j < north.size(); j++) { auto[x2, y2] = north[j].first; ll ind2 = north[j].second; if(x1 >= x2) continue; if(y1 >= y2) continue; ll time1 = abs(x1 - x2); ll time2 = abs(y1 - y2); if(time1 == time2) { deaths.push_back({time1, {ind1, ind2}}); } } } for(int i = 0; i < west.size(); i++) { auto[x1, y1] = west[i].first; ll ind1 = west[i].second; for(int j = 0; j < south.size(); j++) { auto[x2, y2] = south[j].first; ll ind2 = south[j].second; if(x1 <= x2) continue; if(y1 <= y2) continue; ll time1 = abs(x1 - x2); ll time2 = abs(y1 - y2); if(time1 == time2) { deaths.push_back({time1, {ind1, ind2}}); } } for(int j = 0; j < north.size(); j++) { auto[x2, y2] = north[j].first; ll ind2 = north[j].second; if(x1 <= x2) continue; if(y1 >= y2) continue; ll time1 = abs(x1 - x2); ll time2 = abs(y1 - y2); if(time1 == time2) { deaths.push_back({time1, {ind1, ind2}}); } } } for(int i = 0; i < south.size(); i++) { auto[x1, y1] = south[i].first; ll ind1 = south[i].second; for(int j = 0; j < north.size(); j++) { auto[x2, y2] = north[j].first; ll ind2 = north[j].second; if(x1 != x2) continue; ll time = abs(y1 - y2) / 2; deaths.push_back({time, {ind1, ind2}}); } } for(int i = 0; i < east.size(); i++) { auto[x1, y1] = east[i].first; ll ind1 = east[i].second; for(int j = 0; j < west.size(); j++) { auto[x2, y2] = west[j].first; ll ind2 = west[j].second; if(y1 != y2) continue; ll time = abs(x1 - x2) / 2; deaths.push_back({time, {ind1, ind2}}); } } sort(all(deaths)); si left; for(int i = 0; i < n; i++) left.insert(i); for(int i = 0; i < deaths.size();) { ll curTime = deaths[i].first; si del; while(i < deaths.size() && deaths[i].first == curTime) { ll ind1 = deaths[i].second.first, ind2 = deaths[i].second.second; if(!left.count(ind1) || !left.count(ind2)) { i++; continue; } del.insert(ind1); del.insert(ind2); i++; } for(auto x : del) left.erase(x); } for(auto x : left) cout << x + 1 << '\n'; return 0; }
#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...