# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339046 | beksultan04 | Ants (IZhO12_ants) | C++14 | 1 ms | 364 KiB |
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;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int dp[200][200],w[N];
deque <pair<pii,int>> v[3];
bool comp(pair<pii,int> a,pair<pii,int> b){
if (b.fr.sc == a.fr.sc)ret (a.fr.fr < b.fr.fr);
ret (b.fr.sc < a.fr.sc);
}
main(){
int n,m,k,t,i,j;
scan2(n,m)
scan2(k,t)
for (i=1;i<=k;++i){
int x,y,a;
scan3(x,y,a)
if (a == 1){
x += (t%(n*2));
if (x >= n){
a=3;
x = n - (x - n);
}
w[i] = 1;
}
else if (a == 2){
y += (t%(m*2));
if (y >= m){
a = 4;
y = m-(y - m);
}
w[i]=2;
}
else if (a == 3){
x -= (t%(n*2));
if (x <= 0){
a=1;
x = n - (x + n);
}
w[i]=1;
}
else if (a == 4){
y -= (t%(m*2));
if (y <= 0){
y = m - (m + y);
a = 2;
}
w[i]=2;
}
v[w[i]].pb({{x,y},a});
}
sort(all(v[1]));
sort(all(v[2]),comp);
for (i=1;i<=k;++i){
cout <<v[w[i]][0].fr.fr<<" ";
cout <<v[w[i]][0].fr.sc<<" ";
cout <<v[w[i]][0].sc<<"\n";
v[w[i]].pop_front();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |