QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#419775 | #67. Two Transportations | CharlieVinnie | 0 | 82ms | 22212kb | C++20 | 3.8kb | 2024-05-24 11:07:14 | 2024-05-24 11:07:17 |
Judging History
Azer
#include "Azer.h"
#include "bits/stdc++.h"
#ifdef DEBUG
#include "PrettyDebug.hpp"
#else
#define debug(...) [](){}()
#define debuga(...) [](){}()
#endif
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
using namespace std; typedef long long ll;
namespace Azer{
constexpr int N=2e3+5; using pii = pair<int,int>;
int n,dis[N],vis[N],mn,cur,qwq; vector<pii> to[N]; int STATE,WAIT,CURRENT,RESULT;
int getmin() { int u=-1; For(i,0,n-1) if(!vis[i]&&(u==-1||dis[i]<dis[u])) u=i;;; return u; }
void InitA(int _n,int m,vector<int> U,vector<int> V,vector<int> C){
n=_n; For(i,0,m-1) to[U[i]].emplace_back(V[i],C[i]),to[V[i]].emplace_back(U[i],C[i]);
For(i,1,n) dis[i]=1e9;; dis[0]=0; cur=0;
mn=getmin(); Rev(i,8,0) SendA(dis[mn]>>i&1);
STATE=0; WAIT=9;
}
void ReceiveA(bool x){
// cerr<<"ReceiveA "<<x<<'\n';
assert(WAIT); CURRENT=CURRENT<<1|x; if(--WAIT) return; else RESULT=CURRENT,CURRENT=0;
if(STATE==0){
if(dis[mn]<=cur+RESULT){
// cerr<<"A: mn="<<mn<<'\n';
Rev(i,10,0) SendA(mn>>i&1);
vis[mn]=1; cur=dis[mn];
for(auto [v,e]:to[mn]) dis[v]=min(dis[v],dis[mn]+e);
mn=getmin(); if(mn==-1) return;
Rev(i,8,0) SendA((dis[mn]-cur)>>i&1);
STATE=0; WAIT=9;
}
else{
STATE=1; WAIT=11; qwq=cur+RESULT;
}
}
else{
mn=RESULT; //cerr<<"A: got mn="<<mn<<'\n';
vis[mn]=1; cur=dis[mn]=qwq;
for(auto [v,e]:to[mn]) dis[v]=min(dis[v],dis[mn]+e);
mn=getmin(); if(mn==-1) return Answer(),void();
Rev(i,8,0) SendA((dis[mn]-cur)>>i&1);
STATE=0; WAIT=9;
}
}
vector<int> Answer(){
return vector<int>(dis,dis+n);
}
} // namespace
void InitA(int N, int A, std::vector<int> U, std::vector<int> V,std::vector<int> C) {
Azer::InitA(N,A,U,V,C);
}
void ReceiveA(bool x) {
Azer::ReceiveA(x);
}
std::vector<int> Answer() {
return Azer::Answer();
}
Baijan
#include "Baijan.h"
#include "bits/stdc++.h"
#ifdef DEBUG
#include "PrettyDebug.hpp"
#else
#define debug(...) [](){}()
#define debuga(...) [](){}()
#endif
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
using namespace std; typedef long long ll;
namespace Baijan{
constexpr int N=2e3+5; using pii = pair<int,int>;
int n,dis[N],vis[N],mn,cur,qwq; vector<pii> to[N]; int STATE,WAIT,CURRENT,RESULT;
int getmin() { int u=-1; For(i,0,n-1) if(!vis[i]&&(u==-1||dis[i]<dis[u])) u=i;;; return u; }
void InitB(int _n,int m,vector<int> U,vector<int> V,vector<int> C){
n=_n; For(i,0,m-1) to[U[i]].emplace_back(V[i],C[i]),to[V[i]].emplace_back(U[i],C[i]);
For(i,1,n) dis[i]=1e9;; cur=0;
mn=getmin(); Rev(i,8,0) SendB(dis[mn]>>i&1);
STATE=0; WAIT=9;
}
void ReceiveB(bool x){
// cerr<<"ReceiveB "<<x<<'\n';
assert(WAIT); CURRENT=CURRENT<<1|x; if(--WAIT) return; else RESULT=CURRENT,CURRENT=0;
if(STATE==0){
if(dis[mn]<cur+RESULT){
// cerr<<"B: mn="<<mn<<'\n';
Rev(i,10,0) SendB(mn>>i&1);
vis[mn]=1; cur=dis[mn];
for(auto [v,e]:to[mn]) dis[v]=min(dis[v],dis[mn]+e);
mn=getmin(); if(mn==-1) return;
Rev(i,8,0) SendB((dis[mn]-cur)>>i&1);
STATE=0; WAIT=9;
}
else{
STATE=1; WAIT=11; qwq=cur+RESULT;
}
}
else{
mn=RESULT; //cerr<<"B: got mn="<<mn<<'\n';
vis[mn]=1; cur=dis[mn]=qwq;
for(auto [v,e]:to[mn]) dis[v]=min(dis[v],dis[mn]+e);
mn=getmin(); if(mn==-1) return;
Rev(i,8,0) SendB((dis[mn]-cur)>>i&1);
STATE=0; WAIT=9;
}
}
} // namespace
void InitB(int N, int B, std::vector<int> S, std::vector<int> T,std::vector<int> D) {
Baijan::InitB(N,B,S,T,D);
}
void ReceiveB(bool y) {
Baijan::ReceiveB(y);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4056kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 1 0 1 1 0 1 0 0 -1 -1
input:
output:
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
result:
wrong answer 2nd lines differ - expected: '2417', found: '1000000000'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 8
Accepted
time: 1ms
memory: 3888kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 -1 -1
input:
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 4284kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 1 1 0 1 0 1 0 1 -1 -1
input:
output:
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
result:
wrong answer 2nd lines differ - expected: '128264', found: '1000000000'
Subtask #3:
score: 0
Wrong Answer
Test #14:
score: 8
Accepted
time: 0ms
memory: 3968kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 -1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 1 0 -1 0 1 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 1 -1 0 0 0 0 0 0 1 0 0 1 1 1 0 1 1 1 0 0 0 1 -1 1 0 0 1 1 0 1 1 1 -1 0 1 0 1 1 1 0 1 1 -1 0 1 0 0 0 1 1 0 0 -1 0 0 0 1 1 1 1 0 0 -1 0 0 0 0 0 1 1 0 1 1 1 0...
output:
-1 0 0 0 0 0 0 0 0 0 -1 1 1 0 1 0 0 1 0 1 -1 0 0 1 1 0 1 1 0 0 -1 0 0 1 1 0 1 0 1 0 -1 0 0 0 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 0 -1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 1 -1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 1 0 0 0 0 -1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 1 1 -1 1 1 0 1 1 0 1 0 0 0 1 0...
input:
output:
0 3328 4161 4895 4209 3745 3720 4315 3313 4008 2104 3319 3666 3501 3499 3359 4244 3853 1906 392 2028 3840 3209 2376 3001 5530 2494 3340 5583 3653 3624 3798 4121 2243 4252 2165 4289 2935 6032 5124 5255 1362 3336 5054 4411 6329 4444 2299 2294 3848 5170 3200 1544 3953 3577 5969 6227 3533 4569 2619 2738...
result:
ok 2000 lines
Test #15:
score: 8
Accepted
time: 1ms
memory: 3800kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 -1 -1
input:
output:
0
result:
ok single line: '0'
Test #16:
score: 0
Wrong Answer
time: 1ms
memory: 4304kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 1 1 1 1 1 1 1 1 -1 -1
input:
output:
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
result:
wrong answer 2nd lines differ - expected: '420095', found: '1000000000'
Subtask #4:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 1ms
memory: 3920kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 1 0 0 1 1 -1 -1
input:
output:
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
result:
wrong answer 2nd lines differ - expected: '1881', found: '1000000000'
Subtask #5:
score: 0
Wrong Answer
Test #38:
score: 0
Wrong Answer
time: 0ms
memory: 4228kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 -1 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 -1 -1
input:
output:
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
result:
wrong answer 2nd lines differ - expected: '3467', found: '1000000000'
Subtask #6:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 1ms
memory: 4000kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 1 0 1 1 0 0 0 0 -1 -1
input:
output:
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
result:
wrong answer 2nd lines differ - expected: '4745', found: '1000000000'
Subtask #7:
score: 0
Wrong Answer
Test #64:
score: 16
Accepted
time: 6ms
memory: 4108kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 -1 1 0 0 0 1 1 1 0 1 0 0 1 0 0 0 1 1 1 1 0 -1 1 0 0 0 0 1 1 0 0 1 1 1 1 1 0 1 0 1 1 1 -1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 0 0 1 1 0 -1 1 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 -1 0 1 1 1 1 1 0 0 0 1 0 0 0 1 1 1 1 1 0 1 -1 0 0 0 0 0 1 0 1 0 1 0...
output:
-1 0 0 0 0 0 0 0 0 0 -1 1 1 1 1 1 0 0 1 1 -1 1 1 1 1 1 0 0 1 1 -1 1 1 1 1 1 0 0 1 1 -1 1 0 0 0 1 0 1 0 0 -1 1 0 0 0 1 0 0 1 1 -1 0 0 1 1 1 1 1 1 1 -1 1 1 1 1 0 1 0 0 1 -1 0 1 1 1 1 1 0 1 1 -1 1 1 0 0 0 0 0 0 0 -1 1 1 1 1 0 0 1 1 0 -1 0 1 0 0 0 0 0 0 1 -1 1 1 0 1 0 1 1 1 0 -1 1 1 1 0 1 0 1 0 0 -1 1 1...
input:
output:
0 25855 513884 451446 379664 463677 147972 259014 115396 537065 61376 510191 95200 328777 282337 199131 72153 405843 215292 529082 413220 99569 275396 215884 52889 281825 182731 64473 510973 545141 417123 190844 319517 483688 15462 490221 521781 384795 539004 457181 146029 122086 1730 31958 265013 7...
result:
ok 2000 lines
Test #65:
score: 16
Accepted
time: 73ms
memory: 22212kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 -1 0 0 0 0 1 0 1 0 1 -1 0 0 0 0 0 1 1 1 1 -1 0 0 0 0 0 1 0 0 1 -1 0 0 0 0 0 0 1 1 1 -1 0 0 0 0 1 1 0 1 0 -1 0 0 0 0 1 1 0 0 1 -1 0 0 0 0 1 0 1 0 0 -1 0 0 0 0 0 1 1 1 0 -1 0 0 0 0 0 1 0 0 0 -1 0 0 0 0 1 0 1 1 1 -1 0 0 0 0 1 0 0 0 1 -1 0 0 0...
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 1 1 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 1 1 0 -1 1 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 -1 1 0 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 -1 0 1 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 0 1 -1 ...
input:
output:
0 6187 1398 17 6163 4742 4598 2337 2237 6475 6001 5268 2245 6132 4925 1482 4253 1962 6642 2449 2704 3396 5449 2492 706 835 1879 3203 6855 4265 546 1231 2390 2300 4651 1353 1673 6724 6753 360 4275 6749 3400 1385 2945 6010 5339 226 2511 4558 1033 4708 4330 1882 1185 3535 5071 3843 1252 110 6571 6727 3...
result:
ok 2000 lines
Test #66:
score: 16
Accepted
time: 82ms
memory: 20348kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 -1 1 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 1 1 0 0 -1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 1 0 0 0 0 1 0 0 1 0 -1 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 -1 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 0 1 0 1 0 0 0 0 1 1 0 1 0 0 -1 0 0 0 0 0 ...
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 0 1 0 1 0 1 0 0 -1 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 1 1 1 0 1 0 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 1 1 -1 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 1 -1 0 0 0 0 0 0 1 0 1 0 1 1 1 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 0 -1 0 0 0 0 0 0...
input:
output:
0 5455 4313 3996 4463 4115 2413 1141 7939 4669 5854 7806 7612 3394 7713 441 4956 1630 751 2070 4241 6754 3518 3736 3158 549 4590 6798 842 1597 7637 3679 6104 7953 5654 3951 1877 2075 5983 6633 5724 2967 2362 527 7670 3759 3471 4089 508 1187 5437 3533 3003 7429 7499 5966 7484 949 1545 1862 542 3370 1...
result:
ok 2000 lines
Test #67:
score: 0
Wrong Answer
time: 3ms
memory: 4376kb
input:
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1
output:
-1 0 0 0 0 0 0 0 0 0 -1 0 0 0 1 0 0 1 1 0 -1 -1
input:
output:
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
result:
wrong answer 2nd lines differ - expected: '79964', found: '1000000000'