Submission #1817023


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
namespace FastIO
{
	static char c;
	static int top,buf[12],f;
	template<typename T>
	inline void read(T& x)
	{
		x=0,c=getchar(),f=1;
		while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
		while(isdigit(c))x=x*10+c-'0',c=getchar();x*=f;
	}
	template<typename T>
	inline void write(T x,int f=0)
	{
		top=0;
		if(x<0)putchar('-'),x=-x;
		do buf[top++]=x%10,x/=10;while(x);
		for(int i=top-1;~i;i--)putchar(buf[i]+48);
		if(f)putchar(f&1?' ':'\n');
	}
}
using FastIO::read;
using FastIO::write;
const int maxn=1e5+5;

int N,L,T,st,a[maxn],dt;

int main()
{
	read(N),read(L),read(T),dt=T%L;
	for(int i=0,w;i<N;i++)
	{
		read(a[i]),read(w);
		if(w==1)
		{
			st=(st+T/L)%N;
			a[i]+=dt;
			if(a[i]>=L)a[i]-=L,st=(st+1)%N;
		}
		else
		{
			st=((st-T/L)%N+N)%N;
			a[i]-=dt;
			if(a[i]<0)a[i]+=L,st=(st+N-1)%N;
		}
	}
	sort(a,a+N);
	for(int i=st;i<st+N;i++)write(a[i%N],2);
	return 0;
}

Submission Info

Submission Time
Task C - Ants on a Circle
User MegaOwIer
Language C++14 (GCC 5.4.1)
Score 700
Code Size 973 Byte
Status AC
Exec Time 27 ms
Memory 1536 KB

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 256 KB
sample_02.txt AC 1 ms 256 KB
subtask_1_01.txt AC 17 ms 1024 KB
subtask_1_02.txt AC 12 ms 768 KB
subtask_1_03.txt AC 26 ms 1536 KB
subtask_1_04.txt AC 27 ms 1536 KB
subtask_1_05.txt AC 4 ms 384 KB
subtask_1_06.txt AC 5 ms 512 KB
subtask_1_07.txt AC 19 ms 1152 KB
subtask_1_08.txt AC 20 ms 1280 KB
subtask_1_09.txt AC 13 ms 896 KB
subtask_1_10.txt AC 11 ms 768 KB
subtask_1_11.txt AC 5 ms 384 KB
subtask_1_12.txt AC 22 ms 1408 KB
subtask_1_13.txt AC 16 ms 1152 KB
subtask_1_14.txt AC 14 ms 1024 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 1 ms 256 KB