Submission #1693729


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=1;
	char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
typedef long long giant;
const int maxn=1e5;
struct ant {
	int x,w;
} a[maxn];
int b[maxn],c[maxn],n,l,t;
giant cs=0;
inline int up(int x) {
	if (x>=0) return x;
	return x%l+l;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in","r",stdin);
#endif
	n=read(),l=read(),t=read();
	for (int i=0;i<n;++i) {
		int &x=a[i].x=read(),&w=a[i].w=(read()==1?1:-1);
		b[i]=c[i]=up(x+w*t)%l;
	}
	for (int i=1;i<n;++i) if (a[i].w!=a[0].w) {
		int d=up((a[0].x-a[i].x)*a[i].w);
		int k=2*t-d;
		if (k<0) continue;
		cs+=1+k/l;
	}
	int p=cs*a[0].w;
	((p%=n)+=n)%=n;
	sort(b,b+n);
	for (int i=0;i<n;++i) if (b[i]==c[0]) {
		int the=i+(i<n-1 && b[i+1]==b[i] && a[0].w==1);
		rotate(b,b+(the>=p?the-p:n-p+the),b+n);
		break;
	}
	for (int i=0;i<n;++i) printf("%d\n",b[i]);
	return 0;
}

Submission Info

Submission Time
Task C - Ants on a Circle
User permui
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1022 Byte
Status TLE
Exec Time 2103 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:23:30: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  freopen("test.in","r",stdin);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
TLE × 2
TLE × 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 TLE 2103 ms 256 KB
sample_02.txt TLE 2103 ms 256 KB
subtask_1_01.txt TLE 2103 ms 256 KB
subtask_1_02.txt TLE 2103 ms 256 KB
subtask_1_03.txt TLE 2103 ms 256 KB
subtask_1_04.txt TLE 2103 ms 256 KB
subtask_1_05.txt TLE 2103 ms 256 KB
subtask_1_06.txt TLE 2103 ms 256 KB
subtask_1_07.txt TLE 2103 ms 256 KB
subtask_1_08.txt TLE 2103 ms 256 KB
subtask_1_09.txt TLE 2103 ms 256 KB
subtask_1_10.txt TLE 2103 ms 256 KB
subtask_1_11.txt TLE 2103 ms 256 KB
subtask_1_12.txt TLE 2103 ms 256 KB
subtask_1_13.txt TLE 2103 ms 256 KB
subtask_1_14.txt TLE 2103 ms 256 KB
subtask_1_15.txt TLE 2103 ms 256 KB
subtask_1_16.txt TLE 2103 ms 256 KB