제출 #1080459

#제출 시각아이디문제언어결과실행 시간메모리
1080459raphaelpNaval battle (CEOI24_battle)C++14
46 / 100
1854 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; struct ship { int x, y; char type; int dirx, diry; }; istream &operator>>(istream &is, ship &s) { is >> s.x >> s.y >> s.type; if (s.type == 'E') s.dirx = 1, s.diry = 0; if (s.type == 'W') s.dirx = -1, s.diry = 0; if (s.type == 'S') s.dirx = 0, s.diry = 1; if (s.type == 'N') s.dirx = 0, s.diry = -1; return is; } void colide(int i, int j, vector<ship> &ships, vector<vector<int>> &colisions) { ship a = ships[i], b = ships[j]; if (a.type == b.type) return; if (a.dirx == 0 && b.dirx == 0 && ((a.y < b.y && a.diry == 1) || (a.y > b.y && a.diry == -1)) && a.x == b.x) colisions.push_back({abs(a.y - b.y) / 2, i, j}); if (a.diry == 0 && b.diry == 0 && ((a.x < b.x && a.dirx == 1) || (a.x > b.x && a.dirx == -1)) && a.y == b.y) colisions.push_back({abs(a.x - b.x) / 2, i, j}); if (a.diry == 0) swap(a, b); if (((a.y < b.y && a.diry == 1) || (a.y > b.y && a.diry == -1)) && ((b.x < a.x && b.dirx == 1) || (b.x > a.x && b.dirx == -1)) && abs(a.x - b.x) == abs(a.y - b.y)) colisions.push_back({abs(a.x - b.x), i, j}); } int main() { int N; cin >> N; vector<ship> ships(N); for (int i = 0; i < N; i++) { cin >> ships[i]; } vector<vector<int>> colisions; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i < j) colide(i, j, ships, colisions); } } sort(colisions.begin(), colisions.end()); vector<int> alive(N, 1000000001); for (int i = 0; i < colisions.size(); i++) { if (alive[colisions[i][1]] >= colisions[i][0] && alive[colisions[i][2]] >= colisions[i][0]) { alive[colisions[i][1]] = colisions[i][0]; alive[colisions[i][2]] = colisions[i][0]; } } for (int i = 0; i < N; i++) if (alive[i] == 1000000001) cout << i + 1 << '\n'; }

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

Main.cpp: In function 'int main()':
Main.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for (int i = 0; i < colisions.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~~~~
#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...