Submission #1812766
Source Code Expand
#include <cstdio>
#include <algorithm>
using namespace std;
#define iter(i, n) for (int i = 1; i <= n; ++i)
#define NR 101000
typedef long long i64;
int n, L, T, x[NR], w[NR], ans[NR];
typedef pair<int, int> pii;
pii y[NR];
#define fi first
#define se second
int N(i64 i) { return (i - 1) % n + 1; }
int main() {
//freopen("13C.in", "r", stdin);
//freopen("13C.out", "w", stdout);
scanf("%d%d%d", &n, &L, &T);
int pos = -1, index;
iter(i, n) {
scanf("%d%d", &x[i], &w[i]);
if (w[i] == 1 && pos == -1) {
pos = x[i];
index = i;
}
y[i] = pii((0ll + x[i] + (w[i] == 1 ? +T : -T) % L + L) % L, w[i]);
}
if (pos == -1) {
iter(i, n) printf("%d\n", y[i].fi);
return 0;
}
i64 d = 0;
iter(i, n) {
if (w[i] == 2) {
d += 2 * (T / L);
int _T = T % L;
if (x[i] < pos) {
if (x[i] + L - 2 * _T < pos) ++d;
if (x[i] + L - 2 * _T < pos - L) ++d;
}
if (x[i] > pos) {
if (x[i] - 2 * _T < pos) ++d;
if (x[i] - 2 * _T < pos - L) ++d;
}
}
}
pii tmp = y[index];
//fprintf(stderr, "!%d %d %lld %d\n", tmp.fi, index, d, T / L);
sort(y + 1, y + n + 1);
iter(i, n) {
if (y[i] == tmp) {
iter(j, n) {
ans[N((j-1) + index + d)] = y[N(i)].fi;
++i;
}
iter(j, n) printf("%d\n", ans[j]);
break;
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Ants on a Circle |
User |
Ketsui |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1360 Byte |
Status |
AC |
Exec Time |
36 ms |
Memory |
3072 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:26:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &n, &L, &T);
^
./Main.cpp:29:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &x[i], &w[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
700 / 700 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt |
All |
sample_01.txt, sample_02.txt, sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
1 ms |
128 KB |
sample_02.txt |
AC |
1 ms |
128 KB |
subtask_1_01.txt |
AC |
21 ms |
1920 KB |
subtask_1_02.txt |
AC |
17 ms |
1536 KB |
subtask_1_03.txt |
AC |
35 ms |
3072 KB |
subtask_1_04.txt |
AC |
36 ms |
3072 KB |
subtask_1_05.txt |
AC |
5 ms |
640 KB |
subtask_1_06.txt |
AC |
8 ms |
768 KB |
subtask_1_07.txt |
AC |
32 ms |
2688 KB |
subtask_1_08.txt |
AC |
33 ms |
2688 KB |
subtask_1_09.txt |
AC |
22 ms |
1792 KB |
subtask_1_10.txt |
AC |
19 ms |
1664 KB |
subtask_1_11.txt |
AC |
5 ms |
512 KB |
subtask_1_12.txt |
AC |
24 ms |
2432 KB |
subtask_1_13.txt |
AC |
21 ms |
2048 KB |
subtask_1_14.txt |
AC |
19 ms |
1920 KB |
subtask_1_15.txt |
AC |
1 ms |
128 KB |
subtask_1_16.txt |
AC |
1 ms |
128 KB |