이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |