QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#303549 | #7951. Magic Cards | PPP# | WA | 16ms | 18144kb | C++17 | 1.7kb | 2024-01-12 18:12:07 | 2024-01-12 18:12:07 |
Judging History
answer
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef long double ld;
int n, k, m, f;
mt19937_64 rnd(228);
typedef unsigned long long ull;
const int maxK = 105;
ull val[maxK];
const int maxN = 500'005;
int cnt[maxN];
vector<int> who[maxN];
ull hsh[maxN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
cin >> n >> k >> m >> f;
for (int i = 0; i < k; i++) {
who[i].resize(m);
val[i] = rnd();
for (int& p : who[i]) {
cin >> p;
cnt[p] += 1;
hsh[p] += val[i];
}
}
vector<int> D;
for (int i = 1; i <= n; i++) {
if (!cnt[i]) D.emplace_back(i);
}
while (f--) {
string s;
cin >> s;
int id = s.find('Y');
if (id == s.npos) {
if (D.size() == 1) {
cout << D[0] << '\n';
}
else {
cout << 0 << '\n';
}
continue;
}
ull S = 0;
for (int x = 0; x < s.size(); x++) {
if (s[x] == 'Y') S += val[x];
}
int ans = -1;
for (int p : who[id]) {
if (hsh[p] == S) {
if (ans != -1) {
ans = -1;
break;
}
ans = p;
}
}
if (ans > 0) {
cout << ans << '\n';
}
else {
cout << 0 << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 18064kb
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: 17932kb
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: 17860kb
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: 3ms
memory: 17920kb
input:
1 1 1 1 1 Y
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 18144kb
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: -100
Wrong Answer
time: 16ms
memory: 17916kb
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:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'