답안 #785103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785103 2023-07-17T05:17:03 Z 반딧불(#10021) Ili (COI17_ili) C++17
100 / 100
398 ms 660 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m, k;
int arr[20002];
int L[20002], R[20002];

int getInput(){
    char c; int x;
    scanf(" %c%d", &c, &x);
    if(c == 'x') return x;
    return x+n;
}

/// �� �迭
bool canZero[20002];
bool canOne[20002];

/// mark �迭. -1�̸� ��Ȯ��, 0�̸� ������ 0, 1�̸� ������ 1.
int mark[20002];

bool markFull(){
    for(int i=k; i>n; i--){
        if(mark[i] == 0){
            if(mark[L[i]] == 1 || mark[R[i]] == 1) return false;
            mark[L[i]] = mark[R[i]] = 0;
        }
    }
    for(int i=1; i<=n; i++) if(mark[i] == -1) mark[i] = 1;
    for(int i=n+1; i<=k; i++){
        if(mark[i] == -1) mark[i] = mark[L[i]] || mark[R[i]];
        else if(mark[i] != (mark[L[i]] || mark[R[i]])) return false;
    }
    return true;
}

int main(){
    scanf("%d %d", &n, &m);
    k = n+m;
    for(int i=1; i<=n; i++) arr[i] = -1;
    for(int i=1; i<=m; i++){
        char c;
        scanf(" %c", &c);
        arr[i+n] = isdigit(c) ? (c-'0') : -1;
    }
    for(int i=n+1; i<=k; i++){
        L[i] = getInput();
        R[i] = getInput();
    }

    /// canOne���� �˻�
    for(int i=1; i<=k; i++) mark[i] = arr[i];
    assert(markFull());
    for(int i=n+1; i<=k; i++) if(mark[i] == 1) canOne[i] = 1;

    for(int i=n+1; i<=k; i++){
        if(arr[i] != -1) continue;
        for(int j=1; j<=k; j++) mark[j] = arr[j];
        mark[i] = 0;
        if(markFull()) canZero[i] = 1;
    }
    for(int i=n+1; i<=k; i++){
        printf("%c", (canOne[i] && canZero[i]) ? '?' : canOne[i] ? '1' : '0');
    }
}

Compilation message

ili.cpp: In function 'int getInput()':
ili.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf(" %c%d", &c, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~~
ili.cpp: In function 'int main()':
ili.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
ili.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 40 ms 496 KB Output is correct
16 Correct 148 ms 516 KB Output is correct
17 Correct 175 ms 560 KB Output is correct
18 Correct 190 ms 596 KB Output is correct
19 Correct 146 ms 528 KB Output is correct
20 Correct 398 ms 652 KB Output is correct
21 Correct 339 ms 660 KB Output is correct
22 Correct 51 ms 624 KB Output is correct
23 Correct 55 ms 652 KB Output is correct
24 Correct 48 ms 644 KB Output is correct
25 Correct 101 ms 636 KB Output is correct
26 Correct 108 ms 636 KB Output is correct
27 Correct 104 ms 596 KB Output is correct
28 Correct 97 ms 640 KB Output is correct
29 Correct 105 ms 640 KB Output is correct
30 Correct 103 ms 644 KB Output is correct
31 Correct 113 ms 596 KB Output is correct
32 Correct 122 ms 612 KB Output is correct