AtCoder Grand Contest 013

Submission #1366069

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

const double eps = 1e-6;
int N, L, T;
int p[100005], d[100005], f[100005], r[100005], aux[100005];

int getIntersections(int x, int y)
{
	if(x > y) y += L;
	if(2 * T <= y - x)  return 0;
	int t = 2 * T - (y - x);
	int 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("%d%d%d", &N, &L, &T);
    for(int i = 0; i < N; i++)
    {
        scanf("%d%d", &p[i], &d[i]);
        if(d[i] == 2)   d[i] = -1;
    }

    int add = T % L;
    for(int 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);
    int pos0 = p[0];
    if(d[0] == 1)   pos0 = (p[0] + add) % L;
    else            pos0 = (p[0] - add + L) % L;

    for(int i = 0; i < N; i++)  aux[i] = f[i];
    for(int i = 0; i < N; i++)
        if(pos0 == f[i])
        {
            for(int j = 0; j < N; j++)
                f[j] = aux[(j + i) % N];
        }

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

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

    for(int i = 0; i < N; i++)
        printf("%d\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ソースコード長 1588 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &N, &L, &T);
^
./Main.cpp:31:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &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 AC 1 ms 256 KB
subtask_1_01.txt WA
subtask_1_02.txt AC 17 ms 1664 KB
subtask_1_03.txt AC 33 ms 3200 KB
subtask_1_04.txt AC 34 ms 3200 KB
subtask_1_05.txt WA
subtask_1_06.txt AC 8 ms 896 KB
subtask_1_07.txt AC 31 ms 2816 KB
subtask_1_08.txt AC 32 ms 2816 KB
subtask_1_09.txt WA
subtask_1_10.txt WA
subtask_1_11.txt AC 5 ms 640 KB
subtask_1_12.txt AC 28 ms 2816 KB
subtask_1_13.txt AC 21 ms 2176 KB
subtask_1_14.txt AC 21 ms 2048 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 1 ms 256 KB