QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#428850 | #6335. Belt Conveyor | Rafi22# | 1 | 151ms | 32000kb | C++20 | 2.2kb | 2024-06-01 22:29:16 | 2024-06-01 22:29:18 |
Judging History
answer
#include "conveyor.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
const int N=100007;
vector<pair<int,int>>G[N];
bool dead[N],odw[N];
int deg[N];
bool is[N];
vector<int>ans;
vector<int>X,Y;
vector<int>V0,V1;
void dfs(int v,int o,int c)
{
//cout<<"XDDD "<<v<<endl;
odw[v]=1;
if(c==0) V0.pb(v);
else V1.pb(v);
for(auto [u,k]:G[v])
{
if(dead[u])
{
if(k>0) X[k-1]=0;
else X[-k-1]=1;
}
if(odw[u]||dead[u]) continue;
deg[v]++;
deg[u]++;
X[abs(k)-1]=rand()%2;
dfs(u,v,c^1);
}
}
void Solve(int n,vector<int>A,vector<int>B)
{
X.resize(n-1,0);
Y.resize(n,0);
ans.resize(n-1);
for(int i=1;i<=n-1;i++)
{
G[A[i-1]].pb({B[i-1],i});
G[B[i-1]].pb({A[i-1],-i});
}
while(true)
{
memset(odw,0,sizeof odw);
for(int i=0;i<n;i++) Y[i]=0;
for(int i=0;i<n-1;i++) X[i]=0;
for(int i=0;i<n;i++) deg[i]=0;
for(int i=0;i<n;i++)
{
if(dead[i]||odw[i]) continue;
V0.clear(),V1.clear();
dfs(i,0,0);
if(rand()%2) swap(V1,V0);
for(auto x:V0) Y[x]=1;
}
/*for(int i=0;i<n;i++) cout<<deg[i]<<" ";
cout<<endl;
cout<<"Q"<<endl;
for(auto x:X) cout<<x<<" ";
cout<<endl;
for(auto x:Y) cout<<x<<" ";
cout<<endl;*/
vector<int>Z=Query(X,Y);
//for(auto x:Z) cout<<x<<" ";
//cout<<endl;
//cout<<"XDD"<<endl;
for(int i=0;i<n;i++)
{
if(Y[i]&&Z[i])
{
//cout<<"KILLL "<<i<<endl;
for(auto [u,k]:G[i])
{
if(!dead[u])
{
if(k>0) ans[k-1]=X[k-1]^1;
else ans[-k-1]=X[-k-1];
is[abs(k)-1]=1;
// cout<<"IS "<<abs(k)-1<<endl;
}
}
dead[i]=1;
}
if(deg[i]==1&&Y[i]&&!Z[i])
{
//cout<<"KILL "<<i<<endl;
for(auto [u,k]:G[i])
{
if(!dead[u])
{
if(k>0) ans[k-1]=X[k-1];
else ans[-k-1]=X[-k-1]^1;
is[abs(k)-1]=1;
// cout<<"IS "<<abs(k)-1<<endl;
}
}
dead[i]=1;
}
}
bool xd=1;
for(int i=0;i<n-1;i++) xd&=is[i];
if(xd) break;
}
// for(auto x:ans) cout<<x<<" ";
// cout<<endl;
Answer(ans);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 1ms
memory: 3860kb
input:
random1 2 0 1 1 0xC321A02965AC2640
output:
Accepted: 1
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
random1 2 1 0 0 0x8A99AD9552B2C218
output:
Accepted: 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
random1 2 1 0 1 0x024D21FA307D148D
output:
Accepted: 1
result:
ok correct
Test #4:
score: 0
Accepted
time: 1ms
memory: 3932kb
input:
random1 2 0 1 0 0x3C96AB23CEB63F75
output:
Accepted: 1
result:
ok correct
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 3860kb
input:
priority 30 10 29 10 13 17 11 2 15 15 27 9 26 18 0 14 1 22 24 29 28 6 22 4 20 15 5 28 4 21 24 3 13 1 8 13 12 8 19 16 3 1 10 24 29 12 8 4 7 2 7 28 25 12 7 2 23 27 22 89058848 6377689 24189123 31671827 205117644 254374430 56016068 6819602 212866321 246625321 274047319 230485311 202854776 280075001 203...
output:
Wrong Answer [8]
result:
wrong answer Token "Wrong" doesn't correspond to pattern "Accepted:"
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 151ms
memory: 32000kb
input:
random1 100000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...
output:
Wrong Answer [8]
result:
wrong answer Token "Wrong" doesn't correspond to pattern "Accepted:"
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%