QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#769124 | #6335. Belt Conveyor | 275307894a | 25 | 75ms | 35372kb | C++17 | 2.3kb | 2024-11-21 16:12:32 | 2024-11-21 16:12:35 |
Judging History
answer
#include "conveyor.h"
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e5+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,X[N],Y[N],vis[N];
vector<int> S[N],st[3];
int d[N];
void make(int x,int La){
int flag=0;
for(int i:S[x]) if(int y=X[i]^Y[i]^x;flag|=(vis[i]==-1),y^La){
d[y]=(d[x]+1)%3;
make(y,x);
}
if(flag) st[d[x]].push_back(x);
if(La){
rotate(S[x].begin(),find(all(S[x]),La),S[x].end());
reverse(all(S[x]));
}
}
void Solve(int nn, vector<int> A, vector<int> B) {
n=nn;
for(int i=0;i<n-1;i++) X[i]=A[i],Y[i]=B[i],vis[i]=-1;
for(int i=0;i<n-1;i++){
S[A[i]].push_back(i);
S[B[i]].push_back(i);
}
while(1){
if(find(vis,vis+n-1,-1)==vis+n-1) break;
for(int o:{0,1,2}) st[o].clear();
make(0,0);
int mx=0;for(int o:{0,1,2}) if(st[o].size()>st[mx].size()) mx=o;
vector<int> x(n-1),y(n);
for(int i:st[mx]) y[i]=1;
for(int i=0;i<n-1;i++)if(~vis[i]){
if(y[X[i]]) x[i]=vis[i]^1;
if(y[Y[i]]) x[i]=vis[i];
}
vector<int> z=Query(x,y);
gdb(1);
for(int i:st[mx]){
if(z[i]){
for(int j:S[i]) if(vis[j]==-1) vis[j]=(i==X[j]),gdb(j);
}else{
int flag=0;
for(int j:S[i]) if(int v=i^X[j]^Y[j];vis[j]==-1&&z[v]){ vis[j]=(i==Y[j]),gdb(j);flag=1;break;}
if(i==10){
gdb(i);
for(int j:S[i]){
int v=i^X[j]^Y[j];
gdb(vis[j],z[v],X[j],Y[j],x[j]);
}
}
assert(flag);
}
}
}
for(int i=0;i<n-1;i++) gdb(vis[i]);
Answer({vis,vis+n-1});
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 0ms
memory: 7312kb
input:
random1 2 0 1 1 0xC321A02965AC2640
output:
Accepted: 1
result:
ok correct
Test #2:
score: 1
Accepted
time: 1ms
memory: 6692kb
input:
random1 2 1 0 0 0x8A99AD9552B2C218
output:
Accepted: 1
result:
ok correct
Test #3:
score: 1
Accepted
time: 1ms
memory: 6896kb
input:
random1 2 1 0 1 0x024D21FA307D148D
output:
Accepted: 1
result:
ok correct
Test #4:
score: 1
Accepted
time: 1ms
memory: 6456kb
input:
random1 2 0 1 0 0x3C96AB23CEB63F75
output:
Accepted: 1
result:
ok correct
Subtask #2:
score: 14
Accepted
Dependency #1:
100%
Accepted
Test #5:
score: 14
Accepted
time: 1ms
memory: 6320kb
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:
Accepted: 4
result:
ok correct
Test #6:
score: 14
Accepted
time: 1ms
memory: 6152kb
input:
random1 30 18 20 12 0 13 2 9 11 24 7 15 26 17 19 23 10 20 16 3 11 24 1 18 19 1 28 22 6 6 26 21 5 27 27 14 15 8 0 17 5 16 3 10 29 13 14 25 28 25 23 8 9 4 2 4 12 7 22 1 0 0 0 1 0 0 1 0 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 1 1 0 1 0x139BEEDAC0AE4AFB
output:
Accepted: 4
result:
ok correct
Test #7:
score: 14
Accepted
time: 0ms
memory: 6504kb
input:
priority 30 15 20 29 0 10 9 28 26 23 6 19 20 8 13 27 27 1 7 16 26 10 4 16 1 18 8 5 14 13 9 22 15 24 29 2 3 19 2 3 17 0 7 14 12 5 6 25 18 25 24 11 4 12 23 11 17 21 28 155983625 867841392 695948077 619352269 127722564 849426565 618649370 326405673 698896139 727112455 131828530 787535071 635627968 4725...
output:
Accepted: 4
result:
ok correct
Test #8:
score: 14
Accepted
time: 1ms
memory: 6952kb
input:
random1 30 11 11 11 11 23 20 11 11 11 26 11 21 11 11 11 27 11 11 11 16 13 17 5 11 11 1 11 14 11 24 28 10 3 11 11 22 25 8 11 29 11 12 15 9 11 19 0 2 11 11 11 11 18 4 11 7 11 6 0 1 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 0xD66348F4E914D783
output:
Accepted: 2
result:
ok correct
Test #9:
score: 14
Accepted
time: 1ms
memory: 6252kb
input:
priority 30 1 7 19 19 21 3 16 25 19 2 4 19 19 22 19 19 27 18 19 24 19 19 19 19 19 19 19 19 28 19 19 29 0 19 19 19 19 15 19 19 10 5 19 6 14 19 19 23 19 8 11 9 26 17 12 13 20 19 175687064 613757478 145110402 817656856 712251185 850089290 510909115 900701092 956086121 136191567 90104148 72809899 345506...
output:
Accepted: 2
result:
ok correct
Test #10:
score: 14
Accepted
time: 1ms
memory: 6656kb
input:
priority 30 22 22 22 16 13 1 13 22 15 6 21 22 2 23 27 22 4 13 3 13 26 5 13 22 9 8 11 25 13 0 14 13 13 29 13 7 18 22 22 13 28 22 13 22 12 22 20 22 24 13 13 10 17 13 22 22 13 19 205508605 212446816 92507839 281454564 232828716 252753556 236784221 262865505 235145960 298570090 277536286 225110287 21565...
output:
Accepted: 2
result:
ok correct
Subtask #3:
score: 10
Accepted
Test #11:
score: 10
Accepted
time: 71ms
memory: 34284kb
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:
Accepted: 4
result:
ok correct
Test #12:
score: 10
Accepted
time: 75ms
memory: 34084kb
input:
priority 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 ...
output:
Accepted: 4
result:
ok correct
Test #13:
score: 10
Accepted
time: 61ms
memory: 35372kb
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:
Accepted: 3
result:
ok correct
Test #14:
score: 10
Accepted
time: 71ms
memory: 34204kb
input:
priority 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 ...
output:
Accepted: 4
result:
ok correct
Subtask #4:
score: 0
Runtime Error
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #15:
score: 0
Runtime Error
input:
random1 100000 80421 79656 7373 22779 46143 23525 47891 79913 37297 20998 75128 48153 63344 14542 7176 46311 14404 86722 64420 35721 9418 16518 68787 60231 62713 24600 3621 36142 16253 35726 59248 8570 29713 29710 65003 65386 98313 32539 48464 79006 7464 99396 45447 11929 44648 44081 94041 40159 307...
output:
Unauthorized output