답안 #753074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753074 2023-06-04T14:21:01 Z Username4132 Ili (COI17_ili) C++14
49 / 100
4000 ms 15940 KB
#include<iostream>
#include<bitset>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
 
const int MAXN=10010;
int n, m, pr[MAXN][2];
bool pb[MAXN][2];
string info, ans;
bitset<MAXN> arr[MAXN], wi[MAXN], brr[MAXN], one("1"), zero("0"), nuli, uni;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> info;
    ans.assign(m, '?');
    forn(i, m){
        char c1, c2;
        int a1, a2;
        cin >> c1 >> a1 >> c2 >> a2;
        --a1, --a2;
        bitset<MAXN> bi1 = c1=='x'? (one<<a1) : arr[a1];
        bitset<MAXN> bi2 = c2=='x'? (one<<a2) : arr[a2];
        arr[i]=bi1|bi2;
        pb[i][0]=(c1=='x'), pb[i][1]=(c2=='x');
        pr[i][0]=a1, pr[i][1]=a2;
    }
    forn(i, m) if(info[i]=='0') nuli|=arr[i];
    nuli=~nuli;
    forn(i, m) if(info[i]=='1') uni|=(1<<i);
    forn(i, m){
        arr[i]&=nuli;
        if(arr[i].count()==0) ans[i]='0';
    }
    forn(i, m) forn(j, n) if((arr[i]&(one<<j)).count()) wi[j]|=(one<<i);
    forn(i, n) if((nuli&(one<<i)).count()==0) wi[i]=~zero;
    forn(i, m){
        bitset<MAXN> b1 = pb[i][0]? wi[pr[i][0]] : brr[pr[i][0]];
        bitset<MAXN> b2 = pb[i][1]? wi[pr[i][1]] : brr[pr[i][1]];
        brr[i]=b1&b2;
    }
    forn(i, m) if(info[i]=='1') forn(j, m) if((brr[i]&(one<<j)).count()) ans[j]='1';
    cout << ans << endl;    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 86 ms 1652 KB Output is correct
9 Correct 45 ms 1424 KB Output is correct
10 Correct 111 ms 1744 KB Output is correct
11 Correct 100 ms 1676 KB Output is correct
12 Correct 117 ms 1624 KB Output is correct
13 Correct 104 ms 1716 KB Output is correct
14 Correct 53 ms 1644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 86 ms 1652 KB Output is correct
9 Correct 45 ms 1424 KB Output is correct
10 Correct 111 ms 1744 KB Output is correct
11 Correct 100 ms 1676 KB Output is correct
12 Correct 117 ms 1624 KB Output is correct
13 Correct 104 ms 1716 KB Output is correct
14 Correct 53 ms 1644 KB Output is correct
15 Execution timed out 4018 ms 15940 KB Time limit exceeded
16 Halted 0 ms 0 KB -