제출 #1140562

#제출 시각아이디문제언어결과실행 시간메모리
1140562adiyerNaval battle (CEOI24_battle)C++20
0 / 100
314 ms65708 KiB
#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define F first
#define S second

using namespace std;

typedef long long ll;

const int N = 2e5 + 11;

ll n;

pair < pair < ll, ll >, ll > a[N];

vector < pair < ll, ll > > v[4];

map < ll, set < pair < ll, ll > > > mp[4];

map < pair < pair < ll, ll >, ll >, bool > del;

signed main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin >> n;
  for(ll i = 1; i <= n; i++){
    char d;
    ll x, y, tp;
    cin >> x >> y >> d;
    if(d == 'E') tp = 0;
    if(d == 'S') tp = 1;
    if(d == 'W') tp = 2;
    if(d == 'N') tp = 3;
    a[i] = {{x, y}, tp};
    mp[tp][x + y].insert({y, x});
    v[tp].push_back({y, x});
  }
  for(ll i = 0; i < 4; i++) sort(all(v[i])), reverse(all(v[i]));
  for(auto [x, y] : v[0]){
    if(mp[1][x + y].empty()) continue;
    auto it = *(--mp[1][x + y].end());
    mp[1][x + y].erase(it);
    del[{{it.S, it.F}, 1}] = 1;
    del[{{y, x}, 0}] = 1;
  }
  for(ll i = 1; i <= n; i++){
    if(del[a[i]]) continue;
    cout << i << ' ';
  }
}
#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...