QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#716120 | #67. Two Transportations | Estelle_N | 0 | 8ms | 3948kb | C++20 | 3.1kb | 2024-11-06 14:24:43 | 2024-11-06 14:24:43 |
Azer
#include "Azer.h"
#include <vector>
using namespace std;
const int N = 2005;
int n, m, num, pos, val, lasdis, vis[N];
vector < int > dis;
vector < pair <int, int> > e[N];
void solve(int u)
{
vis[u] = 1;
for(auto [v, w] : e[u])
dis[v] = min(dis[v], dis[u] + w);
pos = 0;
for(int i = 0; i < N; ++ i)
if(!vis[i] && (dis[i] < dis[pos] || !pos))
pos = i;
val = min(dis[pos] - lasdis, 511);
for(int i = 8; i >= 0; -- i)
SendA(val >> i & 1);
}
void InitA(int N, int A, vector <int> U, vector <int> V, vector <int> C)
{
n = N;
m = A;
dis.resize(N);
for(int i = 0; i < A; ++ i)
{
e[U[i]].push_back({V[i], C[i]});
e[V[i]].push_back({U[i], C[i]});
}
for(int i = 1; i < N; ++ i)
dis[i] = 1000000000;
++ num;
solve(0);
}
int w, cnt, type;
void ReceiveA(bool x)
{
++ cnt;
w = w * 2 + x;
if(type == 0 && cnt == 9)
{
cnt = 0;
if(w < val)
{
lasdis += w;
type = 1;
w = 0;
}
else
{
for(int i = 10; i >= 0; -- i)
SendA(pos >> i & 1);
lasdis += val;
dis[pos] = lasdis;
if(++ num < N)
solve(pos);
w = 0;
}
}
else if(type == 1 && cnt == 11)
{
cnt = 0;
dis[w] = lasdis;
if(++ num < N)
solve(w);
w = 0;
type = 0;
}
}
vector <int> Answer()
{
return dis;
}
Baijan
#include "Baijan.h"
#include <vector>
using namespace std;
const int N = 2005;
int n, m, num, pos, val, lasdis, vis[N];
vector < int > dis;
vector < pair <int, int> > e[N];
void solve(int u)
{
vis[u] = 1;
for(auto [v, w] : e[u])
dis[v] = min(dis[v], dis[u] + w);
pos = 0;
for(int i = 0; i < N; ++ i)
if(!vis[i] && (dis[i] < dis[pos] || !pos))
pos = i;
val = min(dis[pos] - lasdis, 511);
for(int i = 8; i >= 0; -- i)
SendB(val >> i & 1);
}
void InitB(int N, int B, vector <int> S, vector <int> T, vector <int> D)
{
n = N;
m = B;
dis.resize(N);
for(int i = 0; i < B; ++ i)
{
e[S[i]].push_back({T[i], D[i]});
e[T[i]].push_back({S[i], D[i]});
}
for(int i = 1; i < N; ++ i)
dis[i] = 1000000000;
++ num;
solve(0);
}
int w, cnt, type;
void ReceiveB(bool x)
{
++ cnt;
w = w * 2 + x;
if(type == 0 && cnt == 9)
{
cnt = 0;
if(w < val)
{
lasdis += w;
type = 1;
w = 0;
}
else
{
for(int i = 10; i >= 0; -- i)
SendB(pos >> i & 1);
lasdis += val;
dis[pos] = lasdis;
if(++ num < N)
solve(pos);
w = 0;
}
}
else if(type == 1 && cnt == 11)
{
cnt = 0;
dis[w] = lasdis;
if(++ num < N)
solve(w);
w = 0;
type = 0;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 3948kb
input:
0 0 0 0 0 0 0 0 0 -1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 ...
output:
-1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 0 0 0 0 0 1 0 1 1 0 0 -1 0 0 0 1 0 1 1 1 0 1 1 0 0 1 0 0 0 1 1 0 0 1 0 1 1 1 1 0...
input:
output:
result:
wrong answer 1st lines differ - expected: '0', found: ''
Subtask #2:
score: 0
Interactor Runtime Error
Test #7:
score: 0
Interactor Runtime Error
input:
0 0 0 0 0 0 0 0 0 -1 0 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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 -1 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 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 ...
output:
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 -1 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 1 1 0 0 0 0 0 0 0 0 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 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 ...
input:
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #14:
score: 0
Runtime Error
input:
0 0 0 0 0 0 0 0 0 -1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 -1 1 1 1 1 1 0 1 0 0 1 0 0 0 1 1 1 0 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 1 0 ...
output:
-1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 -1 0 1 1 1 0 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 0 1 1 0 1 1 0 1 1 1 1 1 1 0 1 0...
input:
output:
result:
wrong answer 1st lines differ - expected: '0', found: ''
Subtask #4:
score: 0
Interactor Runtime Error
Test #24:
score: 0
Interactor Runtime Error
input:
0 0 0 0 0 0 0 0 0 -1 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 -1 0 1 1 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 ...
output:
-1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 ...
input:
output:
result:
Subtask #5:
score: 0
Interactor Runtime Error
Test #38:
score: 0
Interactor Runtime Error
input:
0 0 0 0 0 0 0 0 0 -1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 ...
output:
-1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 ...
input:
output:
result:
Subtask #6:
score: 0
Interactor Runtime Error
Test #51:
score: 0
Interactor Runtime Error
input:
0 0 0 0 0 0 0 0 0 -1 1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 0 0 0 -1 1 0 1 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