이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Azer.h"
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
#define MAXN 2020
#define pb push_back
#define INF 1001001001LL
namespace {
int N;
//int variable_example[500000];
int cnt;
vector<ii> g[MAXN];
int dist[MAXN];
set<ii> q;
int getA, getB, getCnt = 0;
int biobr = 0;
unordered_map<ll, int> mp;
int las = 0;
} // namespace
void obradiA()
{
ii cu = *q.begin();
q.erase(q.begin());
las = cu.X;
biobr++;//cout<<cu.X<<'/'<<cu.Y<<endl;
for (ii i: g[cu.Y]) {
if (dist[i.X] > dist[cu.Y] + i.Y) {
if (q.count({dist[i.X], i.X})) q.erase({dist[i.X], i.X});
dist[i.X] = dist[cu.Y] + i.Y;
q.insert({dist[i.X], i.X});
}
}
if (q.empty()) {
if (biobr == N) return;
SendA(0);
return;
for (int i = 0; i < 9; i++) SendA(0);
for (int i = 0; i < 11; i++) SendA(0);
return;
}
ii nx = *q.begin();
nx.X = nx.X - cu.X;
if (mp.count(nx.X * INF + nx.Y)) {
//if (mp[nx.Y] > 1) {
SendA(0);
return;
}
SendA(1);
mp[nx.X * INF + nx.Y] = 1;
//mp[nx.Y]++;
for (int i = 0; i < 9; i++) SendA(nx.X & (1 << i));
for (int i = 0; i < 11; i++) SendA(nx.Y & (1 << i));
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V,
std::vector<int> C) {
::N = N;
if (N == 1) return;
for (int i = 0; i < A; ++i) {
//variable_example[i] = U[i] + V[i] - C[i];
g[U[i]].pb({V[i], C[i]});
g[V[i]].pb({U[i], C[i]});
}
for (int i = 0; i < N; i++) {
dist[i] = INF;
}
dist[0] = 0;
q.insert({0, 0});
obradiA();
}
int waitA = 1;
void ReceiveA(bool x) {//cout<<x<<' '<<biobr<<endl;
if (waitA && x) {
waitA = 0;
return;
}
if (waitA && !x) {
obradiA();
return;
}
if (getCnt == 0) {
getA = getB = 0;
}
getCnt++;
if (getCnt <= 9) {
if (x)
getA |= (1 << (getCnt - 1));
}
else if (x)
getB |= (1 << (getCnt - 1 - 9));
if (getCnt == 9 + 11) { //cout << getA <<'.' << getB<<endl;
getA += las;//cout << getA <<'.' << getB<<endl;
mp[getA * INF + getB] = 1;
//mp[getB]++;
waitA = 1;
if (dist[getB] > getA) {
if (q.count({dist[getB], getB})) q.erase({dist[getB], getB});
dist[getB] = getA;
q.insert({dist[getB], getB});
}
getCnt = 0;
obradiA();
}
/*++cnt;
if (cnt < 58000) {
SendA(x);
++cnt;
}*/
}
std::vector<int> Answer() {
if (N == 1) return vector<int>(1, 0);
std::vector<int> ans(N);
for (int k = 0; k < N; ++k) {
ans[k] = dist[k];
//ans[k] = variable_example[k];
}
return ans;
}
#include "Baijan.h"
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
#define MAXN 2020
#define pb push_back
#define INF 1001001001LL
namespace {
int N;
int cnt;
vector<ii> g[MAXN];
int dist[MAXN];
set<ii> q;
int getA, getB, getCnt = 0;
int biobr = 0;
unordered_map<ll, int> mp;
int las = 0;
bool FunctionExample(bool P) {
return !P;
}
} // namespace
void obradiB()
{
ii cu = *q.begin();
q.erase(q.begin());
las = cu.X;
biobr++;//cout<<cu.X<<'|'<<cu.Y<<endl;
for (ii i: g[cu.Y]) {
if (dist[i.X] > dist[cu.Y] + i.Y) {
if (q.count({dist[i.X], i.X})) q.erase({dist[i.X], i.X});
dist[i.X] = dist[cu.Y] + i.Y;
q.insert({dist[i.X], i.X});
}
}
if (q.empty()) {
if (biobr == N) return;
SendB(0);
return;
for (int i = 0; i < 9; i++) SendB(0);
for (int i = 0; i < 11; i++) SendB(0);
return;
}
//if (cu.Y == 0) return;
ii nx = *q.begin();
nx.X = nx.X - cu.X;
if (mp.count(nx.X * INF + nx.Y)) {
//if (mp[nx.Y] > 1) {
SendB(0);
return;
}
SendB(1);
mp[nx.X * INF + nx.Y] = 1;
//mp[nx.Y]++;
for (int i = 0; i < 9; i++) SendB(nx.X & (1 << i));
for (int i = 0; i < 11; i++) SendB(nx.Y & (1 << i));
}
void InitB(int N, int B, std::vector<int> S, std::vector<int> T,
std::vector<int> D) {
::N = N;
if (N == 1) return;
for (int i = 0; i < B; ++i) {
//variable_example[i] = U[i] + V[i] - C[i];
g[S[i]].pb({T[i], D[i]});
g[T[i]].pb({S[i], D[i]});
}
for (int i = 0; i < N; i++) {
dist[i] = INF;
}
dist[0] = 0;
q.insert({0, 0});
obradiB();
}
int waitB = 1;
void ReceiveB(bool y) {//cout<<y<<' '<<biobr<<".\n";
if (waitB && y) {
waitB = 0;
return;
}
if (waitB && !y) {
obradiB();
return;
}
if (getCnt == 0) {
getA = getB = 0;
}
getCnt++;
if (getCnt <= 9) {
if (y)
getA |= (1 << (getCnt - 1));
}
else if (y)
getB |= (1 << (getCnt - 1 - 9));
if (getCnt == 9 + 11) { //cout << getA<<','<<getB<<endl;
getA += las;//cout << getA<<','<<getB<<endl;
mp[getA * INF + getB] = 1;
//mp[getB]++;
waitB = 1;
if (dist[getB] > getA) {
if (q.count({dist[getB], getB})) q.erase({dist[getB], getB});
dist[getB] = getA;
q.insert({dist[getB], getB});
}
getCnt = 0;
obradiB();
}
}
컴파일 시 표준 에러 (stderr) 메시지
Azer.cpp:16:5: warning: '{anonymous}::cnt' defined but not used [-Wunused-variable]
int cnt;
^~~
Baijan.cpp:24:6: warning: 'bool {anonymous}::FunctionExample(bool)' defined but not used [-Wunused-function]
bool FunctionExample(bool P) {
^~~~~~~~~~~~~~~
Baijan.cpp:15:5: warning: '{anonymous}::cnt' defined but not used [-Wunused-variable]
int cnt;
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |