Submission #1366088


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

typedef long long LL;

LL N, L, T;
LL p[100005], d[100005], f[100005], r[100005], aux[100005];

LL getIntersections(LL x, LL y)
{
	if(x > y) y += L;
	if(2 * T <= y - x)  return 0;
	LL t = 2 * T - (y - x);
	LL cnt = t / L + 1;
	if(t % L == 0)  cnt--;
	return cnt;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%lld%lld%lld", &N, &L, &T);
    for(LL i = 0; i < N; i++)
    {
        scanf("%lld%lld", &p[i], &d[i]);
        if(d[i] == 2)   d[i] = -1;
    }

    LL add = T % L;
    for(LL i = 0; i < N; i++)
    {
        if(d[i] == 1)   f[i] = (p[i] + add) % L;
        else            f[i] = (p[i] - add + L) % L;
    }
    sort(f, f + N);
    LL pos0 = p[0];
    if(d[0] == 1)   pos0 = (p[0] + add) % L;
    else            pos0 = (p[0] - add + L) % L;

    for(LL i = 0; i < N; i++)  aux[i] = f[i];
    for(LL i = 0; i < N; i++)
        if(pos0 == f[i])
        {
            if(f[i] == f[i + 1] && d[0] == -1)   i++;
            for(LL j = 0; j < N; j++)
                f[j] = aux[(j + i) % N];
            break;
        }

    LL id = 0;
    for(LL i = 1; i < N; i++)
        if(d[i] != d[0])
        {
            LL cnt = 0;
            if(d[0] == 1)   cnt = getIntersections(p[0], p[i]);
            else            cnt = getIntersections(p[i], p[0]);
            if(d[0] == 1) (id += cnt) %= N;
            else (id += N - (cnt % N) ) %= N;
        }

    for(LL i = 0; i < N; i++)
        r[(id + i) % N] = f[i];

    for(LL i = 0; i < N; i++)
        printf("%lld\n", r[i]);

    return 0;
}

Submission Info

Submission Time
Task C - Ants on a Circle
User bogdan10bos
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1726 Byte
Status AC
Exec Time 39 ms
Memory 5120 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld", &N, &L, &T);
                                      ^
./Main.cpp:32:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld", &p[i], &d[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 256 KB
sample_02.txt AC 1 ms 256 KB
subtask_1_01.txt AC 24 ms 3200 KB
subtask_1_02.txt AC 19 ms 2560 KB
subtask_1_03.txt AC 38 ms 5120 KB
subtask_1_04.txt AC 39 ms 5120 KB
subtask_1_05.txt AC 7 ms 1024 KB
subtask_1_06.txt AC 9 ms 1280 KB
subtask_1_07.txt AC 35 ms 4736 KB
subtask_1_08.txt AC 36 ms 4736 KB
subtask_1_09.txt AC 24 ms 3200 KB
subtask_1_10.txt AC 21 ms 2816 KB
subtask_1_11.txt AC 6 ms 896 KB
subtask_1_12.txt AC 31 ms 4608 KB
subtask_1_13.txt AC 23 ms 3456 KB
subtask_1_14.txt AC 21 ms 3200 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 1 ms 256 KB