C题乱搞过去了
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k,ii[5000007],gg[20007][205];
vector<int>g[205];
unsigned seed;
unsigned rnd(){
unsigned ret=seed;
seed^=seed<<13;
seed^=seed>>17;
seed^=seed<<5;
return ret;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>k>>seed;
for(int i=1;i<=k;i++){
int op=(rnd()%2)+1;
if(op==1){
int j=(rnd()%m)+1;
int x=(rnd()%(n*m))+1;
g[j].push_back(i);
ii[i]=x;
}
else{
int a=(rnd()%n)+1;
int b=(rnd()%m)+1;
gg[a][b]=i;
}
}
int res=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(gg[i][j]==0){
if(g[j].size()>=1)res=res^(ii[g[j][0]]*((i-1)*m+j));
continue;
}
int pos=lower_bound(g[j].begin(),g[j].end(),gg[i][j])-g[j].begin();
if(pos<g[j].size())res=res^(ii[g[j][pos]]*((i-1)*m+j));
}
}
cout<<res<<'\n';
return 0;
}
如果去掉36到39行会超时,加上就可以卡过去。https://ac.nowcoder.com/acm/contest/view-submission?submissionId=74244790


查看15道真题和解析