AtCoder Grand Contest 013

Submission #1366083

Source codeソースコード

#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])
        {
            for(LL j = 0; j < N; j++)
                f[j] = aux[(j + i) % N];
        }

    LL id = 0;
    for(LL i = 1; i < N; i++)
        if(d[i] != d[0])
        {
            double timp = 0.0;
            if(d[0] == 1) (id += getIntersections(p[0], p[i])) %= N;
            else (id += N - (getIntersections(p[i], p[0]) % 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

Task問題 C - Ants on a Circle
User nameユーザ名 Bogdan Sitaru
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1578 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./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]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt
All 0 / 700 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt WA
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 WA
subtask_1_10.txt WA
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