This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (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... |