# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
100667 | ainta | 움직이는 개미 (IZhO12_ants) | C++17 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 * T + 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);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |