Submission #1691623


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 100000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, l, t;
int Ans[N + 5], id_f;
struct Ants { int pos, dir; } a[N + 5];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif 

    scanf("%d%d%d", &n, &l, &t);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i].pos, &a[i].dir);
        int nxt_pos = a[i].pos + (a[i].dir == 1 ? 1 : -1) * t;

        if(i > 0 && a[i].dir != a[0].dir) {
            if(a[i].dir == 2) {
                int dis = (a[i].pos - a[0].pos);
                if((t << 1) >= dis) id_f = (id_f + ((t << 1) - dis) / l + 1) % n;
            }else {
                int dis = (a[0].pos - a[i].pos + l);
                if((t << 1) >= dis) id_f = (id_f - ((t << 1) - dis) / l - 1) % n;
            }
        }
        Ans[i] = (nxt_pos % l + l) % l;
    }

    sort(Ans, Ans + n);
    id_f = (id_f + n) % n;
    for(int i = 0; i < n; ++i) printf("%d\n", Ans[(id_f + i) % n]);

    return 0;
}

Submission Info

Submission Time
Task C - Ants on a Circle
User Wearry
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1717 Byte
Status WA
Exec Time 33 ms
Memory 2304 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37: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:39:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a[i].pos, &a[i].dir);
                                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 8
WA × 12
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 WA 21 ms 1536 KB
subtask_1_02.txt WA 16 ms 1152 KB
subtask_1_03.txt WA 32 ms 2304 KB
subtask_1_04.txt WA 33 ms 2304 KB
subtask_1_05.txt WA 6 ms 512 KB
subtask_1_06.txt WA 8 ms 640 KB
subtask_1_07.txt WA 30 ms 2048 KB
subtask_1_08.txt WA 30 ms 2048 KB
subtask_1_09.txt WA 20 ms 1408 KB
subtask_1_10.txt WA 18 ms 1280 KB
subtask_1_11.txt WA 6 ms 512 KB
subtask_1_12.txt WA 28 ms 2176 KB
subtask_1_13.txt AC 20 ms 1664 KB
subtask_1_14.txt AC 18 ms 1536 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 1 ms 256 KB