Submission #1694841


Source Code Expand

#include <cstdio>

const int N=100005;
typedef long long LL;

LL a[N*3],b[N*3];
int x[N],w[N],ans[N];

int main(){
	int n,L,T;
	scanf("%d%d%d\n",&n,&L,&T);
	LL p=T/L*2,q=T%L*2,ta=0,tb=0;
	for (int i=0;i<n;i++){
		scanf("%d%d\n",&x[i],&w[i]);
		if (w[i]==1) a[++ta]=x[i];
			else b[++tb]=x[i];
	}
	for (int i=1;i<=ta;i++){
		a[i]-=L*2;
		a[i+ta]=a[i]+L;
		a[i+ta*2]=a[i]+L*2;
	}
	for (int i=1;i<=tb;i++){
		b[i+tb]=b[i]+L;
		b[i+tb*2]=b[i]+L*2;
	}
	for (int i=0,l=1,r=1;i<n;i++)
	if (w[i]==1){
		for (;l<=tb*3 && b[l]<=x[i];l++);
		for (;r<=tb*3 && b[r]<x[i]+q;r++);
		ans[(r-l+p*tb+i)%n]=(x[i]+T)%L;
	}
	for (int i=0,l=1,r=1;i<n;i++)
	if (w[i]==2){
		for (;l<=ta*3 && a[l]<=x[i]-q;l++);
		for (;r<=ta*3 && a[r]<x[i];r++);
		ans[((i-r+l-p*ta)%n+n)%n]=(x[i]-T%L+L)%L;
	}
	for (int i=0;i<n;i++) printf("%d\n",ans[i]);
}

Submission Info

Submission Time
Task C - Ants on a Circle
User aufeas
Language C++14 (GCC 5.4.1)
Score 700
Code Size 855 Byte
Status AC
Exec Time 32 ms
Memory 5760 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d\n",&n,&L,&T);
                            ^
./Main.cpp:14:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d\n",&x[i],&w[i]);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 20
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 2176 KB
sample_02.txt AC 1 ms 2176 KB
subtask_1_01.txt AC 20 ms 4352 KB
subtask_1_02.txt AC 16 ms 3712 KB
subtask_1_03.txt AC 32 ms 5760 KB
subtask_1_04.txt AC 32 ms 5760 KB
subtask_1_05.txt AC 5 ms 2688 KB
subtask_1_06.txt AC 8 ms 2944 KB
subtask_1_07.txt AC 30 ms 5376 KB
subtask_1_08.txt AC 30 ms 5504 KB
subtask_1_09.txt AC 19 ms 4352 KB
subtask_1_10.txt AC 17 ms 3968 KB
subtask_1_11.txt AC 5 ms 2432 KB
subtask_1_12.txt AC 27 ms 4992 KB
subtask_1_13.txt AC 21 ms 4608 KB
subtask_1_14.txt AC 19 ms 4352 KB
subtask_1_15.txt AC 1 ms 2176 KB
subtask_1_16.txt AC 1 ms 128 KB