제출 #1222460

#제출 시각아이디문제언어결과실행 시간메모리
1222460AriadnaNaval battle (CEOI24_battle)C++20
12 / 100
99 ms6120 KiB
#include <bits/stdc++.h>
using namespace std;

char dir[4] = {'N', 'S', 'E', 'W'};

struct Ship {
    int x, y, d;
    pair<int, int> move;
    void init() {
        if (d == 0) move = {0, -1};
        else if (d == 1) move = {0, 1};
        else if (d == 2) move = {1, 0};
        else move = {-1, 0};
    }
};

int main() {
    int n;
    cin >> n;
    vector<Ship> s(n);
    for (int i = 0; i < n; ++i) {
        int x, y, d;
        char c;
        cin >> x >> y >> c;
        if (c == 'N') d = 0;
        else if (c == 'S') d = 1;
        else if (c == 'E') d = 2;
        else d = 3;
        s[i].x = x+300;
        s[i].y = y+300;
        s[i].d = d;
        s[i].init();
    }

    int c = 300;
    vector<vector<int>> grid(701, vector<int>(701, -1));
    vector<bool> sink(n, 0);
    for (int j = 0; j <= c; ++j) {
        for (int i = 0; i < n; ++i) {
            if (sink[i]) continue;
            if (grid[s[i].x][s[i].y] != -1) {
                sink[i] = true;;
                sink[grid[s[i].x][s[i].y]] = true;
            } else grid[s[i].x][s[i].y] = i;
        }

        for (int i = 0; i < n; ++i) {
            grid[s[i].x][s[i].y] = -1;
            s[i].x += s[i].move.first;
            s[i].y += s[i].move.second;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (!sink[i]) cout << i+1 << endl;
    }

    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...