Submission #2544676
Source Code Expand
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstdlib>
#include <vector>
#define rep(i, n) for(long i=0; i<(long)(n); ++i)
using namespace std;
// Globals
int n;
const int N=20000;
//int ts[N], xs[N], ys[N];
vector<int> ts, xs, ys;
void input() {
cin >> n;
ts=vector<int>(n);
xs=vector<int>(n);
ys=vector<int>(n);
rep(i, n) cin >> ts[i] >> xs[i] >> ys[i];
}
void solve() {
int now_x=0, now_y=0, now_t=0;
rep (i, n) {
int x=xs[i], y=ys[i], t=ts[i];
int dist = abs(now_x - x) + abs(now_y - y);
int dur = t - now_t;
bool ok = dist <= dur && dist%2 == dur%2;
if (!ok) {
cout << "No" << endl;
return;
}
//printf("%d,%d,%d,%d,%d,%d,%d,%d\n",now_x,x,now_y,y,now_t,t,dist,dur);
now_x=x; now_y=y; now_t=t;
}
cout << "Yes" << endl;
}
int main() {
input();
solve();
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Traveling |
User |
cottoncotton |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
933 Byte |
Status |
AC |
Exec Time |
89 ms |
Memory |
1408 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_000.txt, 0_001.txt, 0_002.txt |
All |
0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
AC |
1 ms |
256 KB |
0_001.txt |
AC |
1 ms |
256 KB |
0_002.txt |
AC |
1 ms |
256 KB |
1_003.txt |
AC |
1 ms |
256 KB |
1_004.txt |
AC |
89 ms |
1408 KB |
1_005.txt |
AC |
84 ms |
1408 KB |
1_006.txt |
AC |
72 ms |
1408 KB |
1_007.txt |
AC |
12 ms |
384 KB |
1_008.txt |
AC |
1 ms |
256 KB |
1_009.txt |
AC |
16 ms |
512 KB |
1_010.txt |
AC |
1 ms |
256 KB |
1_011.txt |
AC |
10 ms |
384 KB |
1_012.txt |
AC |
1 ms |
256 KB |