This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 "icc.h"
vi sets[100];
int A[100],B[100];
void run(int N) {
int i,j,k,l;
for (i = 0; i < N; i++) sets[i].pb(i);
for (i = 0; i < N-1; i++) {
int L = N-i,la,lb;
for (j = 0; (1 << j) < L; j++) {
la = lb = 0;
for (k = 0; k < L; k++) {
if (k & (1 << j)) {
for (l = 0; l < sets[k].size(); l++) A[la++] = sets[k][l]+1;
}
else {
for (l = 0; l < sets[k].size(); l++) B[lb++] = sets[k][l]+1;
}
}
if (query(la,lb,A,B)) break;
}
int l = 1,r = lb;
while (l < r) {
int m = (l+r) / 2;
if (query(la,m,A,B)) r = m;
else l = m+1;
}
int x = B[l-1];
l = 1,r = la;
while (l < r) {
int m = (l+r) / 2;
if (query(m,lb,A,B)) r = m;
else l = m+1;
}
int y = A[l-1];
setRoad(x,y);
for (j = 0; j < L; j++) {
for (k = 0; k < sets[j].size(); k++) {
if (sets[j][k]+1 == x) {
x = j;
break;
}
}
if (k < sets[j].size()) break;
}
for (j = 0; j < L; j++) {
for (k = 0; k < sets[j].size(); k++) {
if (sets[j][k]+1 == y) {
y = j;
break;
}
}
if (k < sets[j].size()) break;
}
if (x > y) swap(x,y);
for (j = 0; j < sets[y].size(); j++) sets[x].pb(sets[y][j]);
sets[y].clear();
if (y != L-1) {
for (j = 0; j < sets[L-1].size(); j++) sets[y].pb(sets[L-1][j]);
}
}
}
Compilation message (stderr)
icc.cpp: In function 'void run(int)':
icc.cpp:70:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (l = 0; l < sets[k].size(); l++) A[la++] = sets[k][l]+1;
~~^~~~~~~~~~~~~~~~
icc.cpp:73:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (l = 0; l < sets[k].size(); l++) B[lb++] = sets[k][l]+1;
~~^~~~~~~~~~~~~~~~
icc.cpp:94:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (k = 0; k < sets[j].size(); k++) {
~~^~~~~~~~~~~~~~~~
icc.cpp:100:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (k < sets[j].size()) break;
~~^~~~~~~~~~~~~~~~
icc.cpp:103:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (k = 0; k < sets[j].size(); k++) {
~~^~~~~~~~~~~~~~~~
icc.cpp:109:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (k < sets[j].size()) break;
~~^~~~~~~~~~~~~~~~
icc.cpp:112:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < sets[y].size(); j++) sets[x].pb(sets[y][j]);
~~^~~~~~~~~~~~~~~~
icc.cpp:115:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < sets[L-1].size(); j++) sets[y].pb(sets[L-1][j]);
~~^~~~~~~~~~~~~~~~~~
icc.cpp:88:22: warning: 'lb' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (query(m,lb,A,B)) r = m;
~~~~~^~~~~~~~~~
icc.cpp:81:22: warning: 'la' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (query(la,m,A,B)) r = m;
~~~~~^~~~~~~~~~
# | 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... |