QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#298442 | #7951. Magic Cards | SolitaryDream# | WA | 112ms | 13980kb | C++17 | 1.5kb | 2024-01-06 10:04:22 | 2024-01-06 10:04:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=5e3+1e2+7;
int n,k,m,q,a[111][N];
bitset<N>f[101][101],ans;
string s;
int vis[500001];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>k>>m>>q;
for(int i=1;i<=k;i++)
{
for(int j=1;j<=m;j++)
cin>>a[i][j],vis[a[i][j]]=1;
sort(a[i]+1,a[i]+m+1);
}
vector<int> no;
for(int i=1;i<=n;i++)
if(!vis[i])
no.push_back(i);
for(int i=1;i<=k;i++)
{
for(int j=1;j<=k;j++)
{
for(int u=1,v=1;u<=m;u++)
{
while(v<=m&&a[j][v]<a[i][u])
v++;
if(a[j][v]==a[i][u])
f[i][j].set(u);
}
}
}
while(q--)
{
cin>>s;
s=' '+s;
int b=-1;
for(int i=1;i<=k;i++)
if(s[i]=='Y')
b=i;
if(b==-1)
{
if(no.size()!=1)
cout<<0<<"\n";
else
cout<<no.back()<<"\n";
}
else
{
ans=f[b][b];
for(int i=1;i<=k;i++)
if(s[i]=='Y')
ans&=f[b][i];
else
ans&=~f[b][i];
if(ans.count()!=1)
cout<<0<<"\n";
else
cout<<a[b][ans._Find_first()]<<"\n";
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7688kb
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: 7668kb
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: 7828kb
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: 7676kb
input:
1 1 1 1 1 Y
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 11976kb
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: 112ms
memory: 13980kb
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'