답안 #1078316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078316 2024-08-27T15:14:12 Z horiaboeriu Infinite Race (EGOI24_infiniterace2) C++17
0 / 100
18 ms 724 KB
#include <stdio.h>
#include <stdlib.h>
#define MAXN 200000
char f[MAXN];//in f[x] este 0 daca x este in fata si 1 daca ea este in fata pe teren
int main()
{
    int n, q, i, x, rez, ul;
    scanf("%d%d", &n, &q);
    rez = ul = 0;
    for (i = 0; i < q; i++) {
        scanf("%d", &x);
        if (x < 0) {
            f[-x] = 0;
        } else {
            if (f[x] > 0 && ul != x) {
                rez++;
                //acum il intrece doar pe x, deci da o tura intreaga si restul din fata ei raman in fata si cele din spate dupa ce face tura vor ajunge in fata
                ul = x;
            }
            f[x] = 1;
        }
    }
    printf("%d\n", rez);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 18 ms 724 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 11 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 18 ms 724 KB Output isn't correct
5 Halted 0 ms 0 KB -