제출 #1134663

#제출 시각아이디문제언어결과실행 시간메모리
1134663saidponNaval battle (CEOI24_battle)C++17
0 / 100
403 ms37704 KiB
#include <bits/stdc++.h>
#define nemeshay ios_base::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
#define int long long
#define sigma signed
#define pb push_back
#define pii pair<int, int>
#define fr first
#define sc second
using namespace std;
const int N = 2e5 + 2, inf = 1e18 + 7;
pair<pii, char> a[N];
int used[N];
int clash(int i, int j) {
    int xi = a[i].fr.fr, yi = a[i].fr.sc, xj = a[j].fr.fr, yj = a[j].fr.sc;
    if (a[i].sc == 'S' && a[j].sc == 'N')
        if (xi == xj && yi < yj) return (abs(yi - yj) + 1) / 2;
    if (a[i].sc == 'N' && a[j].sc == 'S')
        if (xi == xj && yi > yj) return (abs(yi - yj) + 1) / 2;
    if (a[i].sc == 'E' && a[j].sc == 'W')
        if (yi == yj && xi < xj) return (abs(xi - xj) + 1) / 2;
    if (a[i].sc == 'W' && a[j].sc == 'E')
        if (yi == yj && xi > xj) return (abs(xi - xj) + 1) / 2;
    if ((a[i].sc == 'E' && a[j].sc == 'S') || (a[i].sc == 'N' && a[j].sc == 'W'))
        if (xi < xj && yi > yj && abs(xi - xj) == abs(yi - yj)) return abs(xi - xj);
    if ((a[i].sc == 'S' && a[j].sc == 'E') || (a[i].sc == 'W' && a[j].sc == 'N'))
        if (xi > xj && yi < yj && abs(xi - xj) == abs(yi - yj)) return abs(xi - xj);
    if ((a[i].sc == 'N' && a[j].sc == 'E') || (a[i].sc == 'W' && a[j].sc == 'S'))
        if (xi > xj && yi > yj && abs(xi - xj) == abs(yi - yj)) return abs(xi - xj);
    if ((a[i].sc == 'E' && a[j].sc == 'N') || (a[i].sc == 'S' && a[j].sc == 'W'))
        if (xi < xj && yi < yj && abs(xi - xj) == abs(yi - yj)) return abs(xi - xj);
    return inf;
}
sigma main() {
    int n;
    cin >> n;
    set <int> ans;
    for (int i = 1; i <= n; i++) cin >> a[i].fr.fr >> a[i].fr.sc >> a[i].sc;
    sort(a + 1, a + n + 1);
    map <int, vector<int>> pon;
    for (int i = 1; i <= n; i++) ans.insert(i), pon[a[i].fr.fr + a[i].fr.sc].pb(i);
    for (auto j: pon) {
        vector <int> ok;
        for (auto i: j.sc) {
            if (ok.size() && a[i].sc == 'S' && a[ok.back()].sc == 'E') ans.erase(ok.back()), ans.erase(i), ok.pop_back();
            else ok.pb(i);
        }
    }
    for (auto j: ans) cout << j << 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...