Submission #1134270

#TimeUsernameProblemLanguageResultExecution timeMemory
1134270viwlesxqNaval battle (CEOI24_battle)C++20
6 / 100
1498 ms1114112 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long

template<class A, class B>
bool chmin(A &a, const B &b) {
    return a > b ? (a = b) == b : false;
} template<class A, class B>
bool chmax(A &a, const B &b) {
    return a < b ? (a = b) == b : false;
}

const int inf = 1e18;

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n; cin >> n;

    int x[n], y[n];
    char d[n];

    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> d[i];
    }

    vector<array<int, 3>> v;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (d[i] == 'N' && d[j] == 'S') {
                if (x[i] == x[j] && y[i] > y[j]) v.push_back({(y[i] - y[j]) / 2, i, j});
            } else if (d[i] == 'N' && d[j] == 'E') {
                if (x[i] - x[j] == y[i] - y[j]) v.push_back({x[i] - x[j], i, j});
            } else if (d[i] == 'N' && d[j] == 'W') {
                if (x[j] - x[i] == y[i] - y[j]) v.push_back({x[j] - x[i], i, j});
            }

            else if (d[i] == 'S' && d[j] == 'N') {
                if (x[i] == x[j] && y[i] < y[j]) v.push_back({(y[j] - y[i]) / 2, i, j});
            } else if (d[i] == 'S' && d[j] == 'E') {
                if (x[i] - x[j] == y[j] - y[i]) v.push_back({x[i] - x[j], i, j});
            } else if (d[i] == 'S' && d[j] == 'W') {
                if (x[j] - x[i] == y[j] - y[i]) v.push_back({x[j] - x[i], i, j});
            }

            else if (d[i] == 'E' && d[j] == 'S') {
                if (x[j] - x[i] == y[i] - y[j]) v.push_back({x[j] - x[i], i, j});
            } else if (d[i] == 'E' && d[j] == 'N') {
                if (x[j] - x[i] == y[j] - y[i]) v.push_back({x[j] - x[i], i, j});
            } else if (d[i] == 'E' && d[j] == 'W') {
                if (y[i] == y[j] && x[i] < x[j]) v.push_back({(x[j] - x[i]) / 2, i, j});
            }

            else if (d[i] == 'W' && d[j] == 'S') {
                if (x[i] - x[j] == y[i] - y[j]) v.push_back({x[i] - x[j], i, j});
            } else if (d[i] == 'W' && d[j] == 'E') {
                if (y[i] == y[j] && x[j] < x[i]) v.push_back({(x[i] - x[j]) / 2, i, j});
            } else if (d[i] == 'W' && d[j] == 'N') {
                if (x[i] - x[j] == y[j] - y[i]) v.push_back({x[i] - x[j], i, j});
            }
        }
    }

    sort(v.begin(), v.end());

    vector<int> del(n, 0);

    for (auto [t, i, j] : v) {
        if (del[i] && del[i] < t)
            continue;
        if (del[j] && del[j] < t)
            continue;
        del[i] = del[j] = t;
    }

    for (int i = 0; i < n; ++i) {
        if (!del[i]) {
            cout << i + 1 << '\n';
        }
    }
}
#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...