Submission #1691872
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b) for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
const int N = 100000;
const int oo = 0x3f3f3f3f;
template<typename T> T read() {
T n(0), f(1);
char ch = getchar();
for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48;
return n * f;
}
int id_f;
int n, l, t;
struct Ants { int pos, dir; } a[N + 5];
struct Node { int pos, dir, id; } Ans[N + 5];
bool operator < (const Node& a, const Node& b) {
return a.pos < b.pos ? true :
a.pos == b.pos && a.dir < b.dir ? true :
a.pos == b.pos && a.dir == b.dir && a.id < b.id;
}
int main() {
#ifdef Wearry
freopen("data.txt", "r", stdin);
freopen("ans.txt", "w", stdout);
#endif
scanf("%d%d%d", &n, &l, &t);
for(int i = 0; i < n; ++i) {
scanf("%d%d", &a[i].pos, &a[i].dir);
int nxt_pos = a[i].pos + ((a[i].dir == 1) ? 1 : -1) * t;
if(i && a[i].dir != a[0].dir) {
if(a[i].dir == 2) {
int dis = (a[i].pos - a[0].pos);
if((t << 1) >= dis) id_f = (id_f + ((t << 1) - dis) / l + 1) % n;
}else {
int dis = (a[0].pos - a[i].pos + l);
if((t << 1) >= dis) id_f = (id_f - ((t << 1) - dis) / l - 1) % n;
}
}
Ans[i] = (Node) { (nxt_pos % l + l) % l, 2 - a[i].dir, i };
}
id_f = (id_f + n) % n;
int d = 0;
sort(Ans, Ans + n);
for(int i = 0; i < n; ++i) if(Ans[i].id == 0) {
d = (i - id_f + n) % n;
break;
}
rotate(Ans, Ans + d, Ans + n);
for(int i = 0; i < n; ++i) printf("%d\n", Ans[i].pos);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Ants on a Circle |
User |
Wearry |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
2136 Byte |
Status |
AC |
Exec Time |
34 ms |
Memory |
3200 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:44:32: 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:46:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &a[i].pos, &a[i].dir);
^
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 |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
subtask_1_01.txt |
AC |
21 ms |
2048 KB |
subtask_1_02.txt |
AC |
16 ms |
1536 KB |
subtask_1_03.txt |
AC |
33 ms |
3200 KB |
subtask_1_04.txt |
AC |
34 ms |
3200 KB |
subtask_1_05.txt |
AC |
6 ms |
640 KB |
subtask_1_06.txt |
AC |
8 ms |
896 KB |
subtask_1_07.txt |
AC |
30 ms |
2816 KB |
subtask_1_08.txt |
AC |
31 ms |
2816 KB |
subtask_1_09.txt |
AC |
20 ms |
1920 KB |
subtask_1_10.txt |
AC |
18 ms |
1664 KB |
subtask_1_11.txt |
AC |
6 ms |
640 KB |
subtask_1_12.txt |
AC |
28 ms |
2816 KB |
subtask_1_13.txt |
AC |
20 ms |
2176 KB |
subtask_1_14.txt |
AC |
18 ms |
2048 KB |
subtask_1_15.txt |
AC |
1 ms |
256 KB |
subtask_1_16.txt |
AC |
1 ms |
256 KB |