This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
using ii=pair<int,int>;
map<ii,int> memo;
int ask(int a, int b) {
if (memo.count(ii(a,b))) return memo[ii(a,b)];
return memo[ii(a,b)] = Query(0,a,b);
}
void answer(int a, int b) {
assert(a != b);
if (a > b) swap(a,b);
Bridge(a,b);
}
int ind[2005];
vector<int> al[2005];
void Solve(int N) {
FOR(i,1,N-1) FOR(j,i+1,N-1) {
int r = ask(i,j);
if (r != 0) al[0].push_back(r), ++ind[r];
if (r != i) al[r].push_back(i), ++ind[i];
if (r != j) al[r].push_back(j), ++ind[j];
}
queue<int> q;
q.push(0);
while (!q.empty()) {
int u = q.front(); q.pop();
for (int v : al[u]) {
if (--ind[v] == 0) {
q.push(v);
answer(u,v);
}
}
}
}
# | 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... |