QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#389112 | #7951. Magic Cards | kevinyang# | WA | 13ms | 3888kb | C++17 | 1005b | 2024-04-14 02:31:53 | 2024-04-14 02:31:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n,k,m,q;
cin >> n >> k >> m >> q;
vector<int>h(m+1);
for(int i = 1; i<=m; i++){
h[i] = rng();
}
vector<vector<int>>adj(n+1);
for(int i = 1; i<=k; i++){
set<int>s;
for(int j = 1; j<=m; j++){
int x;
cin >> x;
s.insert(x);
}
for(int nxt: s){
adj[nxt].push_back(i);
}
}
map<int,int>hm;
map<int,int>bad;
for(int i = 1; i<=n; i++){
int hsh = 0;
for(int nxt: adj[i]){
hsh^=h[nxt];
}
if(hm.count(hsh)){
bad[hsh] = 1;
}
else{
hm[hsh] = i;
}
}
while(q--){
string s;
cin >> s;
s = " " + s;
int hsh = 0;
for(int i = 1; i<=k; i++){
if(s[i]=='Y'){
hsh^=h[i];
}
}
if(bad[hsh] || !hm.count(hsh)){
cout << "0\n";
}
else{
cout << hm[hsh] << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
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: 0ms
memory: 3888kb
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: 0ms
memory: 3600kb
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: 0ms
memory: 3652kb
input:
1 1 1 1 1 Y
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3888kb
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: 13ms
memory: 3696kb
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: 0ms
memory: 3688kb
input:
2 1 1 2 1 Y N
output:
1 2
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
2 2 1 2 1 2 YN NY
output:
1 2
result:
ok 2 lines
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3704kb
input:
3 2 1 3 1 2 YN NY NN
output:
1 0 0
result:
wrong answer 2nd lines differ - expected: '2', found: '0'