QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#341656 | #7951. Magic Cards | ucup-team2981# | WA | 15ms | 11704kb | C++20 | 1.7kb | 2024-02-29 20:21:24 | 2024-02-29 20:21:27 |
Judging History
answer
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option
#include<bits/stdc++.h>
using namespace std;
#define all(flg) flg.begin(), flg.end()
#define int long long
#define endl "\n"
#define eb emplace_back
#define ii pair<int, int>
#define vi vector<int>
#define ll long long
#define ld long double
const ll mod = (ll)1e18 + 31;
const int maxN = 5e5 + 5;
const ll oo = 1e18 + 7;
int n, a[maxN];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int x, y, z, k, m, o;
int pw2[maxN];
int res[maxN];
void solve(){
memset(res, 0, sizeof(res));
pw2[0] = 1;
for(int i = 1; i <= 205; ++i){
pw2[i] = pw2[i - 1] * 2 % mod;
}
cin >> n >> k >> m >> o;
for(int i = 0; i < k; ++i){
for(int j = 1; j <= m; ++j){
cin >> x; res[x] = (res[x] + pw2[i]) % mod;
}
}
vector<ii> holder;
holder.push_back({-1, -1});
holder.push_back({mod, mod});
for(int i = 1; i <= n; ++i){
holder.push_back({res[i], i});
}
sort(all(holder));
while(o--){
string s; cin >> s;
int comp = 0;
for(int i = 0; i < k; ++i){
if(s[i] == 'Y') comp = (comp + pw2[i]) % mod;
}
int id = lower_bound(all(holder), ii(comp, -1ll)) - holder.begin();
if(id == holder.size() - 1 || id == 0) cout << 0 << endl;
else if(holder[id].first != comp) cout << 0 << endl;
else if(holder[id].first == holder[id - 1].first ||
holder[id].first == holder[id + 1].first) cout << 0 << endl;
else cout << holder[id].second << endl;
}
}
signed main(){
if(fopen("cf.inp", "r")){
// freopen("cf.inp", "r", stdin);
// freopen("cf.out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int o = 1;
while(o--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10144kb
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: 11704kb
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: 11184kb
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: 11496kb
input:
1 1 1 1 1 Y
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 2ms
memory: 9552kb
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: 15ms
memory: 11556kb
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'