제출 #1194948

#제출 시각아이디문제언어결과실행 시간메모리
1194948badge881Infinite Race (EGOI24_infiniterace2)C++20
100 / 100
70 ms9800 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    set<int> s;
    int ans = 0;
    for (int i = 0; i < q; i++)
    {
        int x;
        scanf("%d", &x);
        if (x > 0)
            if (s.count(x))
            {
                ans++;
                s.clear();
                s.insert(x);
            }
            else
                s.insert(x);
        else
            s.erase(-x);
    }
    printf("%d\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...