Submission #1227226

#TimeUsernameProblemLanguageResultExecution timeMemory
1227226dreamxhavaNaval battle (CEOI24_battle)C++20
0 / 100
3095 ms263020 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    cin.tie();
    ios::sync_with_stdio(false);

    vector<int> x(n), y(n);
    vector<char> d(n);
    vector<bool> c(n, true);
    vector<bool> collided(n, false);

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

    int xmax = *max_element(x.begin(), x.end());
    int ymax = *max_element(y.begin(), y.end());

    bool s = true;

    while (s) {
        if(n==2){
                int newx;int newy;
                if(d[0]=='N'||d[0]=='S'){newy=y[0];}
                if(d[0]=='W'||d[0]=='E'){newx=x[0];}
                if(d[1]=='N'||d[1]=='S'){newy=y[1];}
                if(d[1]=='W'||d[1]=='E'){newx=x[1];}
                if((y[1]-newy)==x[0]-newx){
                        collided.push_back(1);
                        collided.push_back(1);
                        s==false;
                    }
                else{
                        collided.push_back(0);
                        collided.push_back(0);
                        s==false;

                    }
        
        }
        else{
        for (int i = 0; i < n; i++) {
            if (!c[i]) continue;

            if (d[i] == 'N') y[i] -= 2;
            else if (d[i] == 'S') y[i] += 2;
            else if (d[i] == 'E') x[i] += 2;
            else if (d[i] == 'W') x[i] -= 2;

            if (x[i] > xmax || x[i] < 0 || y[i] > ymax || y[i] < 0) {
                c[i] = false;
                continue;
            }

            s = true;
        }

        for (int i = 0; i < n; i++) {
            if (!c[i]) continue;
            for (int j = i + 1; j < n; j++) {
                if (!c[j]) continue;
                if (x[i] == x[j] && y[i] == y[j]) {
                    collided[i] = true;
                    collided[j] = true;
                    c[i] = false;
                    c[j] = false;
                }
            }
        }}
    }

    for (int i = 0; i < n; i++) {
        if(collided[i]==0){
            cout<<i+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...