답안 #428108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
428108 2021-06-15T08:07:57 Z 장태환(#7562) Counterspells (CPSPC17_counterspells) C++17
20 / 100
8 ms 460 KB
#include <iostream>
using namespace std;
int cs[2100];
int col[2100];
int par[2100];
int main()
{
    int N;
    cin >> N;
    int i;
    col[0]=0;
    par[0]=-1;
    for(i=1;i<=N;i++)
    {
        cin >> par[i];
        int a=i;
        col[i]=0;
        cs[par[i]]++;
        int ans=0;
        while(a>=0)
        {
            cs[par[a]]-=1-col[a];
            if(!cs[a])
            {
                if(col[a]==1)
                    ans++;
                col[a]=0;
                 cs[par[a]]++;
            }
            else
            {
                if(col[a]==0)
                ans++;

                col[a]=1;
            }
            a=par[a];
        }
        cout << ans<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 3 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 3 ms 204 KB Output is correct
8 Runtime error 7 ms 460 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 3 ms 204 KB Output is correct
8 Runtime error 7 ms 460 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 3 ms 204 KB Output is correct
8 Runtime error 7 ms 460 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -