QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#741377 | #7951. Magic Cards | yuto1115# | TL | 64ms | 15632kb | C++20 | 1.2kb | 2024-11-13 14:14:17 | 2024-11-13 14:14:17 |
Judging History
answer
#include<bits/stdc++.h>
#define rep2(i,j,k) for(ll i = ll(j); i < ll(k); i++)
#define rep(i,k) rep2(i,0,k)
#define rrep2(i,j,k) for(ll i = ll(j)-1; i >= ll(k); i--)
#define rrep(i,k) rrep2(i,k,0)
#define eb emplace_back
#define SZ(a) ll(a.size())
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
const ll inf = LLONG_MAX/4;
bool chmin(auto& a, auto b) {return a>b ? a=b, 1 : 0;}
bool chmax(auto& a, auto b) {return a<b ? a=b, 1 : 0;}
int main(){
cin.tie(0) -> sync_with_stdio(0);
ll n,k,m,f; cin >> n >> k >> m >> f;
const ll M = 5e5+10;
vector<bitset<M>> state(k);
vector<bitset<M>> rev(k);
rep(i,k){
rep(j,m){
ll x; cin >> x;
state[i].set(x-1);
}
rev[i] = state[i];
rep(j,n) rev[i].flip(j);
}
auto calc = [&](ll idx, char v){
if(v == 'Y') return state[idx];
else return rev[idx];
};
while(f--){
string s; cin >> s;
bitset<M> ans = calc(0, s[0]);
rep(i,k){
ans &= calc(i, s[i]);
}
if(ans.count() != 1){
cout << 0 << "\n";
}
else{
ll val = ans._Find_first();
cout << ans._Find_first() + 1 << "\n";
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3864kb
input:
12 4 6 3 1 9 7 11 3 5 2 10 3 6 7 11 4 5 6 7 6 12 8 11 10 9 12 9 YYNY NNNY YNNN
output:
11 8 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 4000kb
input:
13 4 6 4 1 9 7 11 3 5 2 10 3 6 7 11 4 5 6 7 6 12 8 11 10 9 12 9 YYNY NNNY YNNN NNNN
output:
11 8 1 13
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
14 4 6 4 1 9 7 11 3 5 2 10 3 6 7 11 4 5 6 7 6 12 8 11 10 9 12 9 YYNY NNNY YNNN NNNN
output:
11 8 1 0
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 3832kb
input:
1 1 1 1 1 Y
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 5ms
memory: 15456kb
input:
1 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY...
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 11ms
memory: 15632kb
input:
1 100 5000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
2 1 1 2 1 Y N
output:
1 2
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
2 2 1 2 1 2 YN NY
output:
1 2
result:
ok 2 lines
Test #9:
score: 0
Accepted
time: 1ms
memory: 4072kb
input:
3 2 1 3 1 2 YN NY NN
output:
1 2 3
result:
ok 3 lines
Test #10:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
3 3 1 3 1 2 3 YNN NYN NNY
output:
1 2 3
result:
ok 3 lines
Test #11:
score: 0
Accepted
time: 1ms
memory: 3896kb
input:
4 3 1 4 1 2 3 YNN NYN NNY NNN
output:
1 2 3 4
result:
ok 4 lines
Test #12:
score: 0
Accepted
time: 1ms
memory: 4396kb
input:
10 10 1 2 1 1 1 1 1 1 1 1 1 1 YYYYYYYYYY NNNNNNNNNN
output:
1 0
result:
ok 2 lines
Test #13:
score: 0
Accepted
time: 64ms
memory: 15564kb
input:
100 100 1 100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
result:
ok 100 lines
Test #14:
score: 0
Accepted
time: 61ms
memory: 15628kb
input:
101 100 1 101 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
result:
ok 101 lines
Test #15:
score: -100
Time Limit Exceeded
input:
500000 100 5000 50000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 0 1 2 3 4 ...