# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
635195 | PanTkd | Art Collections (BOI22_art) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//
// 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);
}