제출 #1068380

#제출 시각아이디문제언어결과실행 시간메모리
1068380farukNaval battle (CEOI24_battle)C++17
0 / 100
3017 ms23332 KiB
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define mp make_pair using namespace std; typedef long long ll; typedef pair<int, int> pii; struct ship { char c; int x, y, idx; ship() {} ship(char c, int x, int y) : x(x), y(y), c(c) {} bool operator<(const ship& b) const { return pii(x, y) < pii(b.x, b.y); } bool operator==(const ship&b) const { return idx == b.idx; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<ship> guys(n); for (int i = 0; i < n; i++) { cin >> guys[i].x >> guys[i].y >> guys[i].c; guys[i].idx = i + 1; } for (int i = 0; i <= 100; i++) { map<pii, int> coords; for (ship &s : guys) { if (s.c == 'N') s.y--; if (s.c == 'S') s.y++; if (s.c == 'E') s.x++; if (s.y == 'W') s.x--; coords[pii(s.x, s.y)]++; } vector<ship> new_guys; for (ship &s : guys) if (coords[pii(s.x, s.y)] == 1) new_guys.push_back(s); guys = new_guys; } for (ship s : guys) cout << s.idx << "\n"; }

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

Main.cpp: In constructor 'ship::ship(char, int, int)':
Main.cpp:12:12: warning: 'ship::y' will be initialized after [-Wreorder]
   12 |     int x, y, idx;
      |            ^
Main.cpp:11:10: warning:   'char ship::c' [-Wreorder]
   11 |     char c;
      |          ^
Main.cpp:14:5: warning:   when initialized here [-Wreorder]
   14 |     ship(char c, int x, int y) : x(x), y(y), c(c) {}
      |     ^~~~
#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...