QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302972#7951. Magic CardsOOBMABTRAMS#WA 1ms7616kbC++171.1kb2024-01-11 16:21:552024-01-11 16:21:56

Judging History

你现在查看的是最新测评结果

  • [2024-01-11 16:21:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7616kb
  • [2024-01-11 16:21:55]
  • 提交

answer

#import"bits/stdc++.h"
using namespace std;
typedef long long ll;
void solve();
int main(){
    ios::sync_with_stdio(false);
    int T=1;
 //   cin>>T;
    while(T--)solve();
}
const int N=500013;
ll hsh[N];
ll val[N];
int L[N],o[N];
void solve(){
    mt19937_64 rng(random_device{}());
    int n,k,m,f;
    cin>>n>>k>>m>>f;
    for(int i=1;i<=k;i++)hsh[i]=rng();
    for(int i=1;i<=k;i++){
        for(int j=1;j<=m;j++){
            cin>>L[j];
            if(!o[L[j]])val[L[j]]^=hsh[i],o[L[j]]=1;
        }
        for(int j=1;j<=m;j++)o[L[j]]=0;
    }
    vector<int>id(n);
    std::iota(id.begin(), id.end(), 1);
    std::sort(id.begin(), id.end(),[&](int  x,int y){
        return val[x]<val[y];
    });
    map<ll,int>ans;
    ans[val[id[0]]]=id[0];
    for(int i=1;i<n;i++){
        if(val[id[i]]==val[id[i-1]])ans[val[id[i]]]=0;
        else ans[val[id[i]]]=id[i];
    }
    while(f--){
        string s;
        cin>>s;
        ll K=0;
        for(int i=0;i<n;i++)if(s[i]=='Y')K^=hsh[i+1];
        if(!ans.count(K))cout<<0<<'\n';
        else cout<<ans[K]<<'\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7556kb

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: 7596kb

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: 5476kb

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: 7616kb

input:

1 1 1 1
1
Y

output:

1

result:

ok single line: '1'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 7600kb

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:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'