This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include <bits/stdc++.h>
using namespace std;
#include "swaps.h"
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define sz(x) int((x).size())
#define pb push_back
#define s second
#define f first
typedef vector<int> vi;
typedef pair<int, int> pii;
const int NN=510;
bool cmp[NN][NN];
void solve(int n, int v)
{
set<pii> inf;
FOR(i, 1, n+1)
{
FOR(j, i+1, n+1)
{
inf.insert({i,j});
}
}
vi ans(n); FOR(i, 0, n) ans[i]=i+1;
FOR(i, 0, v)
{
set<int> vis;
set<pii> er;
vector<pii> ins;
for(auto it : inf){
int x=it.f, y=it.s;
if(!vis.count(x) && !vis.count(y)){
schedule(x, y);
vis.insert(x);
vis.insert(y);
ins.pb({x,y});
er.insert(it);
}
}
for(auto it : er) inf.erase(it);
vi get=visit();
FOR(j, 0, sz(get))
{
int x=ins[j].f, y=ins[j].s; bool val=get[j];
if(!val){
swap(ans[x-1], ans[y-1]);
}
cmp[x][y]=val;
cmp[y][x]=!val;
}
}
answer(ans);
}
# | 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... |
# | 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... |