Submission #1222174
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N,L,T;
int X[101010],W[101010];
ll ret[101010];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N>>L>>T;
int id=-1;
L*=2;
T*=2;
FOR(i,N) {
cin>>X[i]>>W[i];
X[i]--;
X[i]*=2;
if(W[i]==1 && id==-1) id=i;
}
if(id==-1) {
FOR(i,N) {
X[i]=((X[i]-T)%L+L)%L;
_P("%d\n",X[i]/2+1);
}
return;
}
ll hit=0;
vector<ll> V;
FOR(i,N) {
if(W[i]==1) V.push_back((X[i]+T)%L);
else V.push_back(((X[i]-T)%L+L)%L);
}
sort(ALL(V));
FOR(i,N) if(W[i]==2) {
ll dif=(i>id)?(X[i]-X[id]):(L+X[i]-X[id]);
ll TT=T;
if(dif/2<=TT) {
hit++;
TT-=dif/2;
}
hit+=(2*TT-1)/dif;
}
ll tid=(id+hit)%N;
ll TX=(X[id]+T)%L;
FOR(i,N) if(V[i]==TX) {
FOR(j,N) {
ret[(tid+j)%N]=V[(i+j)%N]/2+1;
}
}
FOR(i,N) _P("%lld\n",ret[i]);
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
Submission Info
Submission Time |
|
Task |
C - Ants on a Circle |
User |
kmjp |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1502 Byte |
Status |
WA |
Exec Time |
37 ms |
Memory |
3700 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 |
WA |
1 ms |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
subtask_1_01.txt |
WA |
22 ms |
2424 KB |
subtask_1_02.txt |
WA |
18 ms |
1912 KB |
subtask_1_03.txt |
WA |
37 ms |
3700 KB |
subtask_1_04.txt |
WA |
35 ms |
3700 KB |
subtask_1_05.txt |
WA |
6 ms |
896 KB |
subtask_1_06.txt |
WA |
9 ms |
1148 KB |
subtask_1_07.txt |
WA |
34 ms |
3316 KB |
subtask_1_08.txt |
WA |
33 ms |
3316 KB |
subtask_1_09.txt |
WA |
23 ms |
2296 KB |
subtask_1_10.txt |
WA |
20 ms |
2040 KB |
subtask_1_11.txt |
WA |
6 ms |
896 KB |
subtask_1_12.txt |
AC |
24 ms |
1792 KB |
subtask_1_13.txt |
WA |
24 ms |
2552 KB |
subtask_1_14.txt |
AC |
20 ms |
2424 KB |
subtask_1_15.txt |
AC |
1 ms |
256 KB |
subtask_1_16.txt |
AC |
1 ms |
256 KB |