이 제출은 이전 버전의 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],done[2000];
int num,c = 0,s = 0,l = 0,r,logr;
}
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,done[i] = 0;
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,done[0] = 1,r = N,logr = 1;
while ((1 << logr) < r) logr++;
for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
}
void ReceiveA(bool x) {
int i,m = -1;
for (i = 0; i < N; i++) {
if (!done[i] && ((m == -1) || (dist[i] < dist[m]))) m = i;
}
if (m == -1) return;
if (s == 0) {
if (dist[m] == ((1 << 20)-1)) {
for (i = 0; i < 9; i++) SendA(1);
}
else {
for (i = 0; i < 9; i++) SendA(((dist[m]-l) >> i) & 1);
}
s = 1;
}
else if (s == 1) {
if (x == 0) s = 2;
else {
int u = 0;
for (i = 0; i < m; i++) {
if (!done[i]) u++;
}
for (i = 0; i < logr; i++) SendA((u >> i) & 1);
l = dist[m];
s = 3;
}
}
else if (s == 2) {
num |= (x << c),c++;
if (c == 9+logr) {
int u = num >> 9;
for (i = 0; i < N; i++) {
if (!done[i]) {
if (u == 0) break;
else u--;
}
}
u = i;
dist[u] = (num & ((1 << 9)-1))+l;
l += (num & ((1 << 9)-1)),s = 3;
m = u;
c = num = 0;
}
}
if (s == 3) {
done[m] = 1;
for (i = 0; i < adjList[m].size(); i++) {
int v = adjList[m][i].first;
dist[v] = min(dist[v],dist[m]+adjList[m][i].second);
}
r--;
if ((logr > 0) && ((1 << (logr-1)) >= r)) logr--;
s = 0;
m = -1;
for (i = 0; i < N; i++) {
if (!done[i] && ((m == -1) || (dist[i] < dist[m]))) m = i;
}
if (m == -1) return;
if (dist[m] == ((1 << 20)-1)) {
for (i = 0; i < 9; i++) SendA(1);
}
else {
for (i = 0; i < 9; i++) SendA(((dist[m]-l) >> i) & 1);
}
s = 1;
}
}
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],done[2000];
int num,c = 0,s = 0,l = 0,r,logr;
}
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,done[i] = 0;
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,done[0] = 1,r = N,logr = 1;
while ((1 << logr) < r) logr++;
for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
SendB(0);
}
void ReceiveB(bool y) {
int i,m = -1;
for (i = 0; i < N; i++) {
if (!done[i] && ((m == -1) || (dist[i] < dist[m]))) m = i;
}
if (s == 0) {
num |= (y << c),c++;
if (c == 9) {
if ((l+(num & ((1 << 9)-1))) < dist[m]) SendB(1),s = 1;
else {
SendB(0);
for (i = 0; i < 9; i++) SendB(((dist[m]-l) >> i) & 1);
int u = 0;
for (i = 0; i < m; i++) {
if (!done[i]) u++;
}
for (i = 0; i < logr; i++) SendB((u >> i) & 1);
l = dist[m];
s = 3;
c = num = 0;
}
}
}
else if (s == 1) {
num |= (y << c),c++;
if (c == 9+logr) {
int u = num >> 9;
for (i = 0; i < N; i++) {
if (!done[i]) {
if (u == 0) break;
else u--;
}
}
u = i;
dist[u] = (num & ((1 << 9)-1))+l;
l += (num & ((1 << 9)-1)),s = 3;
m = u;
c = num = 0;
}
}
if (s == 3) {
done[m] = 1;
for (i = 0; i < adjList[m].size(); i++) {
int v = adjList[m][i].first;
dist[v] = min(dist[v],dist[m]+adjList[m][i].second);
}
r--;
if ((logr > 0) && ((1 << (logr-1)) >= r)) logr--;
s = 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:76:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
~~^~~~~~~~~~~~~~~~~~~
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:124:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < adjList[m].size(); i++) {
~~^~~~~~~~~~~~~~~~~~~
Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:76:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
~~^~~~~~~~~~~~~~~~~~~
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:121:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < adjList[m].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... |