이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
#include "Azer.h"
namespace {
int N;
vpii adjList[2000];
int dist[2000];
priority_queue<pii> H;
int num,c = 0;
int relax(int u) {
int i,j;
for (i = 0; i < adjList[u].size(); i++) {
int v = adjList[u][i].first;
if ((dist[u]+adjList[u][i].second) < dist[v]) {
dist[v] = dist[u]+adjList[u][i].second;
for (j = 10; j >= 0; j--) SendA((v & (1 << j)) > 0);
for (j = 19; j >= 0; j--) SendA((dist[v] & (1 << j)) > 0);
H.push(mp(-dist[v],v));
}
}
}
}
void InitA(int N,int A,vector<int> U,vector<int> V,vector<int> C) {
int i;
::N = N;
for (i = 0; i < N; i++) dist[i] = (1 << 20)-1;
for (i = 0; i < A; i++) {
adjList[U[i]].pb(mp(V[i],C[i]));
adjList[V[i]].pb(mp(U[i],C[i]));
}
dist[0] = 0;
relax(0);
for (i = 10; i >= 0; i--) SendA(0);
for (i = 19; i >= 0; i--) SendA(1);
}
void ReceiveA(bool x) {
int i,j;
num <<= 1,num |= (x == 1),c++;
if (c == 31) {
int u = num >> 20;
//cout<<"A "<<u<<" "<<(num & ((1 << 20)-1))<<endl;
//for(i=0;i<N;i++)cout<<dist[i]<<" ";
//cout<<endl;
if ((num & ((1 << 20)-1)) > 1e6) {
while (!H.empty()) {
u = H.top().second;
int d = -H.top().first;
H.pop();
//cout<<"Pop from H: "<<u<<" "<<d<<endl;
if (d == dist[u]) {
relax(u);
for (i = 10; i >= 0; i--) SendA((u & (1 << i)) > 0);
for (i = 19; i >= 0; i--) SendA(1);
break;
}
}
}
else dist[u] = num & ((1 << 20)-1),H.push(mp(-dist[u],u));
c = num = 0;
}
}
vector<int> Answer() {
int i;
vi ans;
for (i = 0; i < N; i++) ans.pb(dist[i]);
return ans;
}
#define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
#include "Baijan.h"
namespace {
int N;
vpii adjList[2000];
int dist[2000];
int num,c = 0;
}
void InitB(int N,int B,vector<int> S,vector<int> T,vector<int> D) {
int i;
::N = N;
for (i = 0; i < N; i++) dist[i] = (1 << 20)-1;
for (i = 0; i < B; i++) {
adjList[S[i]].pb(mp(T[i],D[i]));
adjList[T[i]].pb(mp(S[i],D[i]));
}
dist[0] = 0;
}
void ReceiveB(bool y) {
int i,j;
num <<= 1,num |= (y == 1),c++;
if (c == 31) {
int u = num >> 20;
//cout<<"B "<<u<<" "<<(num & ((1 << 20)-1))<<endl;
//for(i=0;i<N;i++)cout<<dist[i]<<" ";
//cout<<endl;
if ((num & ((1 << 20)-1)) > 1e6) {
for (i = 0; i < adjList[u].size(); i++) {
int v = adjList[u][i].first;
if ((dist[u]+adjList[u][i].second) < dist[v]) {
dist[v] = dist[u]+adjList[u][i].second;
for (j = 10; j >= 0; j--) SendB((v & (1 << j)) > 0);
for (j = 19; j >= 0; j--) SendB((dist[v] & (1 << j)) > 0);
}
}
for (j = 10; j >= 0; j--) SendB((u & (1 << j)) > 0);
for (j = 19; j >= 0; j--) SendB(1);
}
else dist[u] = num & ((1 << 20)-1);
c = num = 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
Azer.cpp: In function 'int {anonymous}::relax(int)':
Azer.cpp:67:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < adjList[u].size(); i++) {
~~^~~~~~~~~~~~~~~~~~~
Azer.cpp:76:5: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:93:11: warning: unused variable 'j' [-Wunused-variable]
int i,j;
^
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:85:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < adjList[u].size(); i++) {
~~^~~~~~~~~~~~~~~~~~~
# | 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... |