Submission #1691689
Source Code Expand
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int x[100010], w[100010], ans[100010];
PII p[100010];
signed main(void)
{
int n, l, t;
cin >> n >> l >> t;
REP(i, n) {
cin >> x[i] >> w[i];
p[i] = {x[i], w[i]};
}
sort(p, p+n);
// 最初0番のゼッケンの蟻が何番のゼッケンでどの位置になるか
int num = 0, pos = 0;
if(p[0].second == 1) {
num = 0;
FOR(i, 1, n) {
if(p[i].second == 2 && p[i].first-p[0].first<=2*t) num++;
}
pos = (p[0].first + t) % l;
} else {
num = 0;
for(int i=n-1; i>=1; --i) {
if(p[i].second == 1 && p[0].first+(l-p[i].first)<=2*t) num--;
}
// cout << num << endl;
num = ((num%n)+n)%n;
pos = (((p[0].first - t) % l) + l) % l;
}
// cout << num << " " << pos << endl;
// 最終的に蟻がいる位置の集合
VI v;
REP(i, n) {
if(p[i].second == 1) v.PB((p[i].first+t)%l);
else v.PB((((p[i].first-t)%l)+l)%l);
}
sort(ALL(v));
// for(int i: v) cout << i << " "; cout << endl;
int st = -1;
REP(i, n) {
if(v[i] == pos) {st = i; break;}
}
// cout << "st:" << st << endl;
FOR(i, st, n) {
ans[num] = v[i];
num = (num+1)%n;
}
REP(i, st) {
ans[num] = v[i];
num = (num+1)%n;
}
REP(i, n) cout << ans[i] << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Ants on a Circle |
User |
ferin_tech |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2147 Byte |
Status |
WA |
Exec Time |
218 ms |
Memory |
3704 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
WA |
133 ms |
2428 KB |
subtask_1_02.txt |
WA |
110 ms |
1916 KB |
subtask_1_03.txt |
WA |
218 ms |
3704 KB |
subtask_1_04.txt |
WA |
215 ms |
3704 KB |
subtask_1_05.txt |
WA |
33 ms |
768 KB |
subtask_1_06.txt |
WA |
50 ms |
1024 KB |
subtask_1_07.txt |
WA |
204 ms |
3320 KB |
subtask_1_08.txt |
WA |
207 ms |
3320 KB |
subtask_1_09.txt |
WA |
136 ms |
2300 KB |
subtask_1_10.txt |
WA |
116 ms |
2044 KB |
subtask_1_11.txt |
AC |
30 ms |
768 KB |
subtask_1_12.txt |
AC |
189 ms |
3320 KB |
subtask_1_13.txt |
AC |
140 ms |
2556 KB |
subtask_1_14.txt |
AC |
130 ms |
2300 KB |
subtask_1_15.txt |
AC |
1 ms |
256 KB |
subtask_1_16.txt |
AC |
1 ms |
256 KB |