제출 #1044010

#제출 시각아이디문제언어결과실행 시간메모리
1044010VahanAbrahamNaval battle (CEOI24_battle)C++17
20 / 100
3068 ms16580 KiB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <cmath>
#include <vector>
#include <iomanip>
#include <random>
#include <chrono>
#include <cassert>

using namespace std;

#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen(".in", "r", stdin); freopen("j.out", "w", stdout);

ll gcd(ll a, ll b)
{
    if (a == 0 || b == 0) {
        return  max(a, b);
    }
    if (a <= b) {
        return gcd(a, b % a);
    }
    else {
        return gcd(a % b, b);
    }
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

const int N = 300005;
const ll oo = 100000000000000000, MOD = 1000000007;


struct NODE {
    int x, y, x1, y1;
    char d;
};

NODE a[N], ner[N];
bool ok[N];

void solve() {
    int n;
    cin >> n;
    int mx = 0;
    for (int i = 1; i <= n; ++i) {
        char c;
        cin >> a[i].x >> a[i].y >> a[i].d;
        if (a[i].d == 'N') {
            a[i].x1 = 0;
            a[i].y1 = -1;
        }
        if (a[i].d == 'S') {
            a[i].x1 = 0;
            a[i].y1 = 1;
        }
        if (a[i].d == 'W') {
            a[i].x1 = -1, a[i].y1 = 0;
        }
        if (a[i].d == 'E') {
            a[i].x1 = 1, a[i].y1 = 0;
        }
        ner[i] = a[i];
        mx = max(mx, a[i].x);
        mx = max(mx, a[i].y);
    }
    for (int i = 0; i <= mx; ++i) {
        vector<pair<int, pair<int, int>>> vec;
        for (int j = 1; j <= n; ++j) {
            if (ok[j] != 1) {
                ner[j].x += a[j].x1;
                ner[j].y += a[j].y1;
                if (ner[j].x <= mx && ner[j].x>=0 && ner[j].y <= mx && ner[j].y>=0) {
                    vec.pb({ ner[j].x,{ner[j].y,j} });
                }
            }
        }
        if (vec.size() <= 1) {
            break;
        }
        sort(vec.begin(), vec.end());
        for (int j = 0; j < vec.size(); ++j) {
            if (j < vec.size()-1) {
                if (vec[j].fr == vec[j + 1].fr && vec[j].sc.fr == vec[j + 1].sc.fr) {
                    ok[vec[j].sc.sc] = 1;
                }
            }
            if (j > 0) {
                if (vec[j-1].fr == vec[j].fr && vec[j-1].sc.fr == vec[j].sc.fr) {
                    ok[vec[j].sc.sc] = 1;
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (ok[i] != 1) {
            cout << i << endl;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //US
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:65:14: warning: unused variable 'c' [-Wunused-variable]
   65 |         char c;
      |              ^
Main.cpp:100:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |         for (int j = 0; j < vec.size(); ++j) {
      |                         ~~^~~~~~~~~~~~
Main.cpp:101:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |             if (j < vec.size()-1) {
      |                 ~~^~~~~~~~~~~~~~
#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...