제출 #858884

#제출 시각아이디문제언어결과실행 시간메모리
858884waldi자동 인형 (IOI18_doll)C++17
16 / 100
60 ms12516 KiB
#include "doll.h" #include <bits/stdc++.h> #define FOR(i,p,k) for(int i=(p);i<=(k);++i) #define REP(i,n) FOR(i,0,(n)-1) #define ssize(x) (int(x.size())) using namespace std; void create_circuit(int m, vector<int> a){ int n = a.size(); vector<vector<int>> g(m+1); REP(i, n){ if(i) g[a[i-1]].emplace_back(a[i]); else g[0].emplace_back(a[i]); } g[a.back()].emplace_back(0); int maks = 0; FOR(i, 0, m) maks = max(maks, ssize(g[i])); if(maks <= 4){ vector<int> c(m+1, 0); int it = 0; vector<int> x, y; auto nowy = [&](){ x.emplace_back(0); y.emplace_back(0); ++it; }; FOR(i, 0, m) if(g[i].size()){ if(ssize(g[i]) == 1){ c[i] = g[i][0]; } if(ssize(g[i]) == 2){ nowy(); c[i] = -(it-1)-1; x[it-1] = g[i][0]; y[it-1] = g[i][1]; } if(ssize(g[i]) == 3){ nowy(), nowy(), nowy(); c[i] = -(it-1)-1; x[it-1] = -(it-2)-1; y[it-1] = -(it-3)-1; x[it-2] = -(it-1)-1; y[it-2] = g[i][1]; x[it-3] = g[i][0]; y[it-3] = g[i][2]; } if(ssize(g[i]) == 4){ nowy(), nowy(), nowy(); c[i] = -(it-1)-1; x[it-1] = -(it-2)-1; y[it-1] = -(it-3)-1; x[it-2] = g[i][0]; y[it-2] = g[i][2]; x[it-3] = g[i][1]; y[it-3] = g[i][3]; } } /*printf("c: "); for(int i : c) printf("%d ", i); printf("\n"); printf("x: "); for(int i : x) printf("%d ", i); printf("\n"); printf("y: "); for(int i : y) printf("%d ", i); printf("\n");*/ answer(c, x, y); return; } int N = 1; while(N < n) N <<= 1; }
#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...