답안 #26285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26285 2017-06-29T04:34:51 Z 시제연(#1104) Ili (COI17_ili) C++
7 / 100
9 ms 14496 KB
#include <bits/stdc++.h>

using namespace std;

int n, m;
bitset<10000> bit[10100];
char str[10100];
int son[10100][2];

int getn(char str[]) {
    int i, x = 0;
    for (i=0;str[i]>='0'&&str[i]<='9';i++) {
        x *=10;
        x+=str[i]-'0';
    }
    return x;
}

vector<int> vec;
bitset<10000> tmp;
int main() {
    int i, j;

    scanf("%d%d",&n,&m);
    scanf("%s",str);
    for (i=0;i<m;i++) {
        char buf[10];
        for (j=0;j<2;j++) {
            int x = 0;
            scanf("%s",buf);
            if (buf[0]=='c') x+= n;
            x+=getn(buf+1)-1;
            son[i][j] = x;
        }
    }
    for (i=0;i<m;i++) {
        if (son[i][0]<n) bit[i][son[i][0]] = 1;
        else bit[i] |= bit[son[i][0]-n];
        if (son[i][1]<n) bit[i][son[i][1]] = 1;
        else bit[i] |= bit[son[i][1]-n];
    }
    for (i=0;i<m;i++) {
        if (str[i]=='0') tmp |= bit[i];
        if (str[i]=='1') vec.push_back(i);
    }
    for (i=0;i<vec.size();i++) bit[i] &= (~tmp);
    for (i=0;i<m;i++) {
        if (str[i]=='?'&&((tmp|bit[i])==tmp)) str[i]='0';
    }
    for (i=0;i<m;i++) {
        if (str[i]=='?') {
            for (j=0;j<vec.size();j++) if ((bit[i]|bit[vec[j]])==bit[i]) str[i] = '1';
        }
    }
    printf("%s\n",str);

    return 0;
}

Compilation message

ili.cpp: In function 'int main()':
ili.cpp:46:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i=0;i<vec.size();i++) bit[i] &= (~tmp);
               ^
ili.cpp:52:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (j=0;j<vec.size();j++) if ((bit[i]|bit[vec[j]])==bit[i]) str[i] = '1';
                       ^
ili.cpp:24:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
ili.cpp:25:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",str);
                    ^
ili.cpp:30:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%s",buf);
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14496 KB Output is correct
2 Correct 0 ms 14496 KB Output is correct
3 Correct 0 ms 14496 KB Output is correct
4 Correct 0 ms 14496 KB Output is correct
5 Correct 6 ms 14496 KB Output is correct
6 Correct 3 ms 14496 KB Output is correct
7 Correct 0 ms 14496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14496 KB Output is correct
2 Correct 0 ms 14496 KB Output is correct
3 Correct 0 ms 14496 KB Output is correct
4 Correct 0 ms 14496 KB Output is correct
5 Correct 6 ms 14496 KB Output is correct
6 Correct 3 ms 14496 KB Output is correct
7 Correct 0 ms 14496 KB Output is correct
8 Incorrect 9 ms 14496 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14496 KB Output is correct
2 Correct 0 ms 14496 KB Output is correct
3 Correct 0 ms 14496 KB Output is correct
4 Correct 0 ms 14496 KB Output is correct
5 Correct 6 ms 14496 KB Output is correct
6 Correct 3 ms 14496 KB Output is correct
7 Correct 0 ms 14496 KB Output is correct
8 Incorrect 9 ms 14496 KB Output isn't correct
9 Halted 0 ms 0 KB -