# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
231340 | 2020-05-13T11:31:02 Z | bensonlzl | Broken Device (JOI17_broken_device) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "Annalib.h" using namespace std; typedef long long ll; int usable[155], ans[155]; void Anna(int N, long long X, int K, int P[]){ mt19937 rng(8537293); vector<int> v; for (int i = 0; i < N; ++i){ usable[i] = 1; ans[i] = 0; v.push_back(i); } shuffle(v.begin(),v.end(),rng); for (int i = 0; i < K; ++i){ usable[P[i]] = 0; } for (int i = 0; i < N; i += 2){ if (usable[v[i]] && usable[v[i+1]]){ if (X%3 == 0){ ans[v[i]] = 0; ans[v[i+1]] = 1; } else if (X%3 == 1){ ans[v[i]] = 1; ans[v[i+1]] = 0; } else{ ans[v[i]] = 1; ans[v[i+1]] = 1; } X /= 3; } else if (usable[v[i]] && !usable[v[i+1]] && (X%3 == 1)){ ans[v[i]] = 1; ans[v[i+1]] = 0; X /= 3; } else if (!usable[v[i]] && usable[v[i+1]] && (X%3 == 0)){ ans[v[i]] = 1; ans[v[i+1]] = 1; X /= 3; } else{ ans[v[i]] = ans[v[i+1]] = 0; } } for (int i = 0; i < N; ++i){ Set(i,ans[i]); } }