QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578657 | #9319. Bull Farm | wangwx | WA | 0ms | 36784kb | C++14 | 2.2kb | 2024-09-20 20:40:44 | 2024-09-20 20:40:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=2e3+5,inf=4e6+10;
string s;
int a,b,c;
int cnt[mxn];
int t,n,l,q;
int bucket[mxn];
int h[mxn],tot;
struct E{
int nx,to,w;
}e[inf];
int mp[mxn][mxn];
void add(int u,int v,int i){
e[++tot]={h[u],v,i};
h[u]=tot;
}
void sx(int x){
for(int i=1;i<=n;++i){
if(mp[i][cnt[i]]) continue;
add(i,cnt[i],x);
mp[i][cnt[i]]=1;
}
}
void dx(int x){
int l,r;
for(int i=1;i<=n;++i){
if(bucket[i]==0) l=i;
if(bucket[i]==2) r=i;
}
for(int i=1;i<=n;++i){
if(mp[i][l]) continue;
if(cnt[i]==r) add(i,l,x);
mp[i][l]=1;
}
}
int jm(string &s){
int js=0;
memset(bucket,0,sizeof bucket);
int zc=s.size();
for(int i=0;i<zc;i+=2){
cnt[i/2+1]=(s[i]-'0')*50+(s[i+1]-'0');
bucket[cnt[i/2+1]]++;
if(bucket[cnt[i/2+1]]==1) js++;
}
if(js==n) return 1;
else if(js==n-1) return 2;
else return 0;
}
int vis[mxn];
int check(int c){
queue<int> q;
q.push(a);vis[a]=1;
memset(vis,0,sizeof vis);
while(!q.empty()){
int now=q.front();
q.pop();
for(int i=h[now];~i;i=e[i].nx){
int cs=e[i].w;
int to=e[i].to;
if(cs>c) continue;
if(vis[to]) continue;
q.push(to);
vis[to]=1;
}
}
if(vis[b]) return 1;
else return 0;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>t;
while(t--){
memset(mp,0,sizeof mp);
tot=0;
memset(h,-1,sizeof h);
cin>>n>>l>>q;
for(int i=1;i<=l;++i){
cin>>s;
int ed=jm(s);
if(!ed) continue;
else if(ed==1) sx(i);
else dx(i);
}
for(int i=1;i<=q;++i){
cin>>s;
a=(s[0]-'0')*50+s[1]-'0';
b=(s[2]-'0')*50+s[3]-'0';
c=(s[4]-'0')*50+s[5]-'0';
if(check(c)) cout<<'1';
else cout<<'0';
}
cout<<'\n';
}
return 0;}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 36784kb
input:
2 5 2 4 0305040201 0404040404 030300 020500 050102 020501 6 2 4 030603010601 010203060504 030202 060402 050602 060401
output:
0011 0100
result:
wrong answer 1st lines differ - expected: '1011', found: '0011'