제출 #590759

#제출 시각아이디문제언어결과실행 시간메모리
590759Namnamseo코알라 (APIO17_koala)C++17
37 / 100
87 ms316 KiB
#include "koala.h" #include <algorithm> #include <cstdio> #include <vector> #include <numeric> using namespace std; using vi=vector<int>; #define all(v) v.begin(), v.end() vi Play(vi q) { vi ret(q.size()); playRound(q.data(), ret.data()); return ret; } int minValue(int N, int W) { vi v(N); v[0] = 1; vi res = Play(v); if (res[0] >= 1) res[0] -= 1; for (int i=0; i<N; ++i) if (!res[i]) return i; return 0; } int maxValue(int N, int W) { vi larger(N); iota(larger.begin(), larger.end(), 0); while (larger.size() > 1u) { vi mask(N); int afford = W / larger.size(); for (int i:larger) mask[i] = afford; auto res = Play(mask); vi larger_new; for (int i:larger) if (res[i]) larger_new.push_back(i); larger = larger_new; } return larger[0]; } int greaterValue(int N, int W) { int l = 0, r = 15; vi q(N); for (;;) { int m = (l+r)/2; q[0] = q[1] = m; vi res = Play(q); if (res[0] != res[1]) { return res[0] < res[1]; } if (!res[0]) r = m; else l = m; } return 0; } void allValues(int N, int W, int *P) { if (W == 2*N) { vi buf(N); fill(all(buf), 2); vi tmp = Play(buf); vi large, small; for (int i=0; i<N; ++i) { if (tmp[i] > 2) { large.push_back(i); } else { small.push_back(i); } } vi ss, sl, ls, ll; fill(all(buf), 0); for (int x : large) buf[x] = 3; tmp = Play(buf); for (int x : large) { if (tmp[x] > 3) ll.push_back(x); else ls.push_back(x); } for (int x : small) { if (tmp[x] > 0) sl.push_back(x); else ss.push_back(x); } fill(all(buf), 0); auto Sort = [&](vi &v) { sort(all(v), [&](const int& a, const int& b) { buf[a] = buf[b] = 100; tmp = Play(buf); buf[a] = buf[b] = 0; return tmp[a] < tmp[b]; }); }; Sort(ss); Sort(sl); Sort(ls); Sort(ll); vi out; out.insert(out.end(), all(ss)); out.insert(out.end(), all(sl)); out.insert(out.end(), all(ls)); out.insert(out.end(), all(ll)); for (int i=0; i<N; ++i) P[out[i]] = 1+i; } else { // TODO: Implement Subtask 5 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } }
#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...