제출 #255314

#제출 시각아이디문제언어결과실행 시간메모리
255314arayi자동 인형 (IOI18_doll)C++17
84 / 100
183 ms9972 KiB
#include "doll.h" //Arayi //#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <queue> #include <stack> #include <algorithm> #include <math.h> #include <vector> #include <cstring> #include <ctime> #include <set> #include <bitset> #include <map> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <ctime> #include <climits> #include <cassert> #include <chrono> #include <random> #include <complex> #define fr first #define sc second #define MP make_pair #define ad push_back #define PB push_back #define fastio ios_base::sync_with_stdio(false); cin.tie(0); #define lli long long int #define y1 arayikhalatyan #define j1 jigglypuff #define ld long double #define itn int #define pir pair<int, int> #define all(x) (x).begin(), (x).end() #define str string #define enl endl #define en endl #define cd complex<long double> #define vcd vector<cd> #define vii vector<int> #define vlli vector<lli> using namespace std; const int N = 1e6 + 30; const lli mod = 1e9 + 7; const ld pi = acos(-1); const int T = 238; const ld e = 1e-13; int n, m, i1 = 1; vii fp; vii c, x, y; bool col[N]; void rec(int v) { if (!col[v]) { col[v] = true; if (x[v] == mod) { x[v] = fp.back(); fp.pop_back(); rec(0); } else if (x[v] < 0) rec(-x[v] - 1); else if (x[v] > 0) rec(0); } else { col[v] = false; if (y[v] == mod) { y[v] = fp.back(); fp.pop_back(); rec(0); } else if (y[v] < 0) rec(-y[v] - 1); else if (y[v] > 0) rec(0); } } void mk() { vii sm = fp; int n = sm.size(); int er = 0; while ((1 << er) < n) er++; int ss = (1 << er) - n; vii nax, nw; nax.ad(i1); i1++; x.ad(mod), y.ad(mod); for (int i = 1; i < er; i++) { for (int j = nax.size() - 1; j >= 0; j--) { nw.ad(i1); y[nax[j] - 1] = -i1, i1++; nw.ad(i1); x[nax[j] - 1] = -i1, i1++; x.ad(mod), x.ad(mod), y.ad(mod), y.ad(mod); } if (ss & (1 << (er - i))) { x[nax[0] - 1] = -1; i1--; x.pop_back(); y.pop_back(); nw.pop_back(); } reverse(all(nw)); swap(nax, nw); nw.clear(); } if (ss & 1) { x[nax[0] - 1] = -1; } reverse(all(fp)); rec(0); } void create_circuit(int M, vector<int> A) { n = A.size(); m = M; c.resize(m + 1); c[0] = A[0]; for (int i = 1; i <= m; i++) c[i] = -1; fp = A; reverse(all(fp)); fp.pop_back(); reverse(all(fp)); fp.ad(0); mk(); answer(c, x, y); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...