| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 100668 | ainta | Ants (IZhO12_ants) | C++17 | 2 ms | 384 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<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int W, H, K, T;
struct AA {
	int x, y, dir;
}Res[110];
struct point {
	int loc, ck, num;
	bool operator<(const point &p)const {
		return loc != p.loc ? loc < p.loc : ck < p.ck;
	}
}Z[110];
vector<point>X[110], Y[110];
void Go(vector<point>&U, int M, int TT) {
	int i;
	sort(U.begin(), U.end());
	int sz = U.size();
	for (i = 0; i < sz;i++) {
		auto t = U[i];
		int x = (t.loc + t.ck * TT + 2 * M) % (2 * M);
		int ck = t.ck;
		if (x > M)x = 2 * M - x, ck = -ck;
		if (x == M)ck = -1;
		if (x == 0)ck = 1;
		Z[i] = { x,ck,i };
	}
	sort(Z, Z + sz);
	for (i = 0; i < sz; i++) {
		U[i].loc = Z[i].loc;
		U[i].ck = Z[i].ck;
	}
}
int main() {
	int i, j, x, y, d;
	scanf("%d%d%d%d", &W, &H, &K, &T);
	for (i = 1; i <= K; i++) {
		scanf("%d%d%d", &x, &y, &d);
		if (d & 1) {
			Y[y].push_back({ x,2-d,i });
		}
		else {
			X[x].push_back({ y,3-d,i });
		}
	}
	for (i = 0; i <= W; i++) {
		if (X[i].empty())continue;
		Go(X[i], H, T % (2 * H));
		for (auto &t : X[i]) {
			Res[t.num] = { i, t.loc, 3 - t.ck };
		}
	}
	for (i = 0; i <= H; i++) {
		if (Y[i].empty())continue;
		Go(Y[i], W, T % (2 * W));
		for (auto &t : Y[i]) {
			Res[t.num] = { t.loc, i, 2 - t.ck };
		}
	}
	for (i = 1; i <= K; i++)printf("%d %d %d\n", Res[i].x, Res[i].y, Res[i].dir);
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
