답안 #427897

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427897 2021-06-15T04:27:36 Z 반딧불(#7617) Counterspells (CPSPC17_counterspells) C++17
60 / 100
1000 ms 2432 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int par[200002];
int cnt[200002]; /// �ڽ� ���� �߿��� �������� ���� ��
bool col[200002];
int ans;

int main(){
    scanf("%d", &n);
    par[0] = -1;
    for(int i=1; i<=n; i++){
        int x;
        scanf("%d", &x);
        col[i] = 1;
        par[i] = x;
        ans = 0;

        int c = 1;
        while(x>=0){
            cnt[x] += c;
            if(cnt[x]==1 && c==1){
                col[x] = 0;
                c = -1;
                ans++;
            }
            else if(!cnt[x] && c==-1){
                col[x] = 1;
                c = 1;
                ans++;
            }
            else c = 0;
            x = par[x];
        }

        printf("%d\n", ans);
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 4 ms 332 KB Output is correct
9 Correct 147 ms 356 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 372 KB Output is correct
13 Correct 9 ms 332 KB Output is correct
14 Correct 24 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 4 ms 332 KB Output is correct
9 Correct 147 ms 356 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 372 KB Output is correct
13 Correct 9 ms 332 KB Output is correct
14 Correct 24 ms 376 KB Output is correct
15 Correct 32 ms 1268 KB Output is correct
16 Execution timed out 1085 ms 660 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 2428 KB Output is correct
2 Correct 66 ms 2016 KB Output is correct
3 Correct 32 ms 1348 KB Output is correct
4 Correct 48 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 4 ms 332 KB Output is correct
9 Correct 147 ms 356 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 4 ms 372 KB Output is correct
13 Correct 9 ms 332 KB Output is correct
14 Correct 24 ms 376 KB Output is correct
15 Correct 32 ms 1268 KB Output is correct
16 Execution timed out 1085 ms 660 KB Time limit exceeded
17 Halted 0 ms 0 KB -