This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// main.cpp
//
// Created by Panagiotis Chadjicostas on
// Copyright © Panagiotis Hadjicostas. All rights reserved.
//
#include "art.h"
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
typedef int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define fo(i,a,b) for(int i = a; i<=b; i++)
#define f(i,b) for(int i=0;i<b;i++)
#define F first
#define S second
#define sz size
#define ls s,m,idx<<1
#define rs m+1,e,idx<<1|1
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);
///////////////////////////////////////////////////////////////////////
//
// --- Sample implementation for the task art ---
//
// To compile this program with the sample grader, place:
// art.h art_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
// g++ -std=c++17 art_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
template<typename T>
void pop_front(std::vector<T> &v)
{
if (v.size() > 0) {
v.erase(v.begin());
}
}
void solve(int N) {
vi a;
for(ll i=1;i<=N;i++)a.push_back(i);
vi ans(N+1,ll());
ll &n=N;
vector<ii> P(N+1,ii());
for(ll i=1;i<=N;i++){
P[a[0]].F=publish(a);
P[a[N-1]].S=P[a[0]].F;
a.push_back(a[0]);
pop_front(a);
/*
vi temp;
temp.push_back(i);
for(ll j=1;j<=N;j++)if(j!=i)temp.push_back(j);
ll ans1=publish(temp);
temp.clear();
for(ll j=1;j<=N;j++)if(j!=i)temp.push_back(j);
temp.push_back(i);
ll ans2=publish(temp);
*/
// erxomai sto telos, osous eimai meg (esto k) +k parapona, -(n-k)=-n+k
// --'--
// ans1=ans2-n+2k
// k = (ans1-ans2 + n) /2
/*
ll idx=(ans1-ans2 + n) /2;
ans[idx]=i;
*/
}
for(ll i=1;i<=N;i++){
ll idx=(P[i].F-P[i].S+N)/2;
ans[idx]=i;
}
vi ans3;
for(ll i=0;i<n;i++){
ans3.push_back(ans[i]);
}
answer(ans3);
}
Compilation message (stderr)
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(v.size() != N) {
| ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(v.size() != N) {
| ~~~~~~~~~^~~~
# | 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... |