제출 #1073414

#제출 시각아이디문제언어결과실행 시간메모리
1073414ProtonDecay314Naval battle (CEOI24_battle)C++17
6 / 100
36 ms7116 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef pair<int, int> pi; typedef vector<pi> vpi; typedef vector<bool> vb; #define fi first #define se second #define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false) #define pb push_back struct ship { int x, y, d; }; vpi dir = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; typedef vector<ship> vs; vi solve(int n, vs& s) { int linf = max(abs(s[0].x - s[1].x), abs(s[0].y - s[1].y)); int s0x = s[0].x + dir[s[0].d].fi * linf; int s0y = s[0].y + dir[s[0].d].se * linf; int s1x = s[1].x + dir[s[1].d].fi * linf; int s1y = s[1].y + dir[s[1].d].se * linf; vi ans; if(s0x == s1x && s0y == s1y) return ans; else { ans.pb(1); ans.pb(2); return ans; } } int main() { IOS; int n; cin >> n; vs s; for(int i = 0; i < n; i++) { int x, y; char d; cin >> x >> y; cin >> d; int dv; if(d == 'N') dv = 0; if(d == 'E') dv = 1; if(d == 'S') dv = 2; if(d == 'W') dv = 3; s.pb({x, y, dv}); } vi ans = solve(n, s); for(int v : ans) { cout << v << "\n"; } cout << flush; return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:66:13: warning: 'dv' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |         s.pb({x, y, dv});
      |         ~~~~^~~~~~~~~~~~
#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...