이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(auto i=(a);i<(b); ++i)
#define uwu(i,a, b) for(auto i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 400001;
int n, m;
ttgl arr[mxN];
int st[mxN];
/*void answer(vector<int> c, vector<int> x, vector<int> y) {
for(int k: c) {
cout<<k<<" ";
}
cout<<"\n";
for(int k: x) {
cout<<k<<" ";
}
cout<<"\n";
for(int k: y) {
cout<<k<<" ";
}
cout<<"\n";
}*/
void create_circuit(int M, vector<int> A) {
n = A.size();
m = M;
if(n==1) {
vector<int> c(m+1, 0);
vector<int> x(0);
vector<int> y(0);
c[0] = A[0];
answer(c, x, y);
}
vector<int> c(m+1, -1);
c[0] = A[0];
int h = 0;
int num = 1;
while(num < n) {
num*=2;
h++;
}
int cnt = 1;
owo(i, 0, num) {
int curr = 0;
int nxt;
if(i < n-1) {
owo(j, 0, h-1) {
if(st[curr]) {
if(arr[curr].second==0) {
arr[curr].second = -(cnt++);
}
nxt = -arr[curr].second;
}else {
if(arr[curr].first==0) {
arr[curr].first = -(cnt++);
}
nxt = -arr[curr].first;
}
st[curr]^=1;
curr = nxt;
}
if(st[curr]) {
arr[curr].second = A[i+1] + 1;
}else {
arr[curr].first = A[i+1] + 1;
}
st[curr]^=1;
}else {
owo(j, 0, h) {
if(st[curr]) {
if(arr[curr].second==0&&i==num-1) {
arr[curr].second = 1;
nxt = 0;
break;
}
nxt = -arr[curr].second;
}else {
nxt = -arr[curr].first;
}
st[curr]^=1;
if(nxt==0) break;
curr = nxt;
}
}
}
vector<int> x(cnt);
vector<int> y(cnt);
owo(i, 0, cnt) {
x[i] = arr[i].first - 1;
y[i] = arr[i].second - 1;
}
answer(c, x, y);
}
/*int N, M;
vector<int> in;
int main() {
//freopen("file.in", "r", stdin);
//freopen("file.out", "w", stdout);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
cin.tie(0)->sync_with_stdio(0);
cin>>N>>M;
in.resize(N);
owo(i, 0, N) {
cin>>in[i];
}
create_circuit(M, in);
return 0;
}*/
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
3 | #pragma GCC optimization ("O3")
|
doll.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
4 | #pragma GCC optimization ("unroll-loops")
|
# | 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... |