Submission #8813691
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);
template<class T> inline bool chmin(T &a,T b){
if (a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if (a<b){
a=b;
return true;
}
return false;
}
const ll LAP_MAX=1e9;
int main(){
ll N,L,T; cin >> N >> L >> T;
vector<ll> X(N),pos(N);
vector<int> W(N);
rep(i,N){
cin >> X[i] >> W[i];
if (W[i]==1) pos[i]=(X[i]+T)%L;
else pos[i]=(X[i]-T+LAP_MAX*L)%L;
}
ll now=0;
rep2(i,1,3){
ll j=3-i;
if (W[0]==i){
vector<ll> collision;
rep(k,N) if (W[k]==j) collision.push_back(X[k]);
ll cnt=collision.size();
ll lap=2*T/L,rest=2*T-lap*L;
if (i==1){
now=(cnt*lap)%N;
ll last=lower_bound(collision.begin(),collision.end(),X[0]+rest)-collision.begin();
now=(now+last)%N;
}
else{
now=(N-(cnt*lap)%N)%N;
ll last=collision.end()-lower_bound(collision.begin(),collision.end(),(X[0]-rest+L)%L);
now=(now-last+N)%N;
}
}
}
ll pos_now=pos[0];
sort(pos.begin(),pos.end());
ll start=lower_bound(pos.begin(),pos.end(),pos_now)-pos.begin();
vector<ll> ans(N);
rep(i,N) ans[(now+i)%N]=pos[(start+i)%N];
rep(i,N) cout << ans[i] << endl;
}
Submission Info
Submission Time |
|
Task |
C - Ants on a Circle |
User |
rniya |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1772 Byte |
Status |
WA |
Exec Time |
217 ms |
Memory |
4080 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 |
AC |
131 ms |
2576 KB |
subtask_1_02.txt |
AC |
104 ms |
2108 KB |
subtask_1_03.txt |
AC |
213 ms |
4080 KB |
subtask_1_04.txt |
AC |
217 ms |
4080 KB |
subtask_1_05.txt |
AC |
34 ms |
768 KB |
subtask_1_06.txt |
AC |
49 ms |
1184 KB |
subtask_1_07.txt |
AC |
205 ms |
3696 KB |
subtask_1_08.txt |
AC |
204 ms |
3696 KB |
subtask_1_09.txt |
AC |
133 ms |
2556 KB |
subtask_1_10.txt |
AC |
116 ms |
2204 KB |
subtask_1_11.txt |
AC |
30 ms |
768 KB |
subtask_1_12.txt |
AC |
189 ms |
3584 KB |
subtask_1_13.txt |
WA |
139 ms |
2812 KB |
subtask_1_14.txt |
WA |
127 ms |
2576 KB |
subtask_1_15.txt |
AC |
1 ms |
256 KB |
subtask_1_16.txt |
AC |
1 ms |
256 KB |