| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 38305 | romanasa | 움직이는 개미 (IZhO12_ants) | C++14 | 0 ms | 2024 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
using namespace std;
typedef long long ll;
map<int, vector<int> > X, Y;
#define TASK "e"
int main() {
#ifndef HOME
	freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
	int w, h, k, t;
	cin >> w >> h >> k >> t;
	
	vector<int> x(k), y(k), d(k);
	
	for (int i = 0; i < k; i++) {
		cin >> x[i] >> y[i] >> d[i];
		if (d[i] == 2 || d[i] == 4) X[x[i]].push_back(i);
		else Y[y[i]].push_back(i);
	}
	
	for (auto c : X) {
		auto &cur = c.second;
		sort(cur.begin(), cur.end(), [&](int a, int b) { return y[a] < y[b]; });
		for (int it = 0; it < t; it++) {
			vector<int> used((int)cur.size());
			for (int i = 0; i + 1 < (int)cur.size(); i++) if (!used[i]) {
				if (y[cur[i]] + 1 == y[cur[i + 1]] && d[cur[i]] == 2 && d[cur[i + 1]] == 4) {
					swap(d[cur[i]], d[cur[i + 1]]);
					used[i] = 1, used[i + 1] = 1;
					continue;
				}
				if (y[cur[i]] + 2 == y[cur[i + 1]] && d[cur[i]] == 2 && d[cur[i + 1]] == 4) {
					swap(d[cur[i]], d[cur[i + 1]]);
					y[cur[i]]++;
					y[cur[i + 1]]--;
					used[i] = 1, used[i + 1] = 1;
					continue;
				}
			}
			for (int i = 0; i < (int)cur.size(); i++) if (!used[i]) {
				if (d[cur[i]] == 2) y[cur[i]]++;
				else y[cur[i]]--; 
			}
			for (int i = 0; i < (int)cur.size(); i++) {
				if (y[cur[i]] == h && d[cur[i]] == 2) d[cur[i]] = 4;
				if (y[cur[i]] == 0 && d[cur[i]] == 4) d[cur[i]] = 2;
			}
		}
	}
	
	for (auto c : Y) {
		auto &cur = c.second;
		sort(cur.begin(), cur.end(), [&](int a, int b) { return x[a] < x[b]; });
		for (int it = 0; it < t; it++) {
			vector<int> used((int)cur.size());
			for (int i = 0; i + 1 < (int)cur.size(); i++) if (!used[i]) {
				if (x[cur[i]] + 1 == x[cur[i + 1]] && d[cur[i]] == 1 && d[cur[i + 1]] == 3) {
					swap(d[cur[i]], d[cur[i + 1]]);
					used[i] = 1, used[i + 1] = 1;
					continue;
				}
				if (x[cur[i]] + 2 == x[cur[i + 1]] && d[cur[i]] == 1 && d[cur[i + 1]] == 3) {
					swap(d[cur[i]], d[cur[i + 1]]);
					x[cur[i]]++;
					x[cur[i + 1]]--;
					used[i] = 1, used[i + 1] = 1;
					continue;
				}
			}
			for (int i = 0; i < (int)cur.size(); i++) if (!used[i]) {
				if (d[cur[i]] == 1) x[cur[i]]++;
				else x[cur[i]]--; 
			}
			for (int i = 0; i < (int)cur.size(); i++) {
				if (x[cur[i]] == w && d[cur[i]] == 1) d[cur[i]] = 3;
				if (x[cur[i]] == 0 && d[cur[i]] == 3) d[cur[i]] = 1;
			}
		}
	}
	
	for (int i = 0; i < k; i++) cout << x[i] << " " << y[i] << " " << d[i] << "\n";
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
