# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100666 | 2019-03-13T06:08:26 Z | cki86201 | Ants (IZhO12_ants) | C++11 | 3 ms | 512 KB |
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <string> #include <algorithm> #include <iostream> #include <functional> #include <unordered_set> #include <bitset> #include <time.h> #include <limits.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) (int)x.size() #define rep(i,n) for(int i=0;i<n;i++) #define all(x) x.begin(),x.end() typedef tuple<int, int, int> t3; int W, H, K, T; vector <pii> X[2][110]; t3 ans[110]; int main() { scanf("%d%d%d%d", &W, &H, &K, &T); for(int i=1;i<=K;i++) { int x, y, d; scanf("%d%d%d", &x, &y, &d); if(d & 1) X[0][y].pb(pii(x, (d == 1 ? i : -i))), get<1>(ans[i]) = y; else X[1][x].pb(pii(y, (d == 2 ? i : -i))), get<0>(ans[i]) = x; } rep(u, 2) { int L = (u == 0 ? W : H); for(int i=1;i<=100;i++) { sort(all(X[u][i])); vector <pii> v; for(pii e : X[u][i]) { int l = (e.Se > 0 ? e.Fi : 2 * L - e.Fi); l = (l + T) % (2 * L); pii f; if(l < L) f = pii(l, 1); else f = pii(2 * L - l, -1); v.pb(f); } sort(all(v)); rep(j, szz(X[u][i])) { int idx = abs(X[u][i][j].Se); pii e = v[j]; if(u == 0) { int di = (e.Se == 1 ? 1 : 3); get<2>(ans[idx]) = di; get<0>(ans[idx]) = e.Fi; } else { int di = (e.Se == 1 ? 2 : 4); get<2>(ans[idx]) = di; get<1>(ans[idx]) = e.Fi; } } } } for(int i=1;i<=K;i++) printf("%d %d %d\n", get<0>(ans[i]), get<1>(ans[i]), get<2>(ans[i])); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 3 ms | 512 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 3 ms | 256 KB | Output is correct |