제출 #266889

#제출 시각아이디문제언어결과실행 시간메모리
266889amoo_safar코알라 (APIO17_koala)C++17
53 / 100
62 ms512 KiB
#include "koala.h" #include <bits/stdc++.h> #define pb push_back using namespace std; int minValue(int n, int w) { assert(n == w); return 0; } int maxValue(int n, int w) { assert(n == w); return 0; } int greaterValue(int n, int w) { assert(n == w); return 0; } int Sum(int l, int r){ return (l + r) * (r - l + 1) / 2;; } int dp[102][102]; int inp[100], out[100]; int ans[100], np; void Solve(vector<int> pos, int L, int R){ int n = np; if(L == R){ ans[pos[0]] = L; return ; } int cnt = dp[L][R]; memset(inp, 0, sizeof inp); for(auto x : pos) inp[x] = cnt; memset(out, 0, sizeof out); playRound(inp, out); vector<int> Le, Bi; for(int i = 0; i < np; i++){ if(inp[i] > 0){ if(inp[i] < out[i]){ Bi.pb(i); } else { Le.pb(i); } } } /* if(Le.empty()){ cerr << "! " << L << " " << R << " -> " << pos.size() << '\n'; //for(int i = 0; i < 100; i++) cerr << inp[i] << ' ' << out[i] << '\n'; cerr << '\n'; } */ assert(!Le.empty()); assert(!Bi.empty()); Solve(Le, L, L + Le.size() - 1); Solve(Bi, L + Le.size(), R); } void allValues(int n, int w, int *P) { if (w == 2 * n) { return ; } for(int i = 1; i <= n; i++){ for(int j = i + 1; j <= n; j++){ int ln = j - i + 1; vector<int> A, B; for(int k = n; k >= 1; k--){ if(i <= k && k <= j) A.pb(k); else B.pb(k); } int val = -1; for(int x = 1; x * ln <= n; x++){ int mx = -1; vector<int> Mx; for(int cn = 0; cn <= ln; cn ++){ if(cn * (x + 1) > n) continue; int res = 0; for(int i2 = 0; i2 < cn; i2 ++) res += A[i2]; int cn2 = min(n - (cn * (x + 1)), (int) B.size()); for(int i2 = 0; i2 < cn2; i2 ++) res += B[i2]; if(res > mx){ mx = res; Mx.clear(); } if(res == mx) Mx.pb(cn); } if(!Mx.empty() && (Mx[0] != 0) && (Mx.back() != ln)){ val = x; } } dp[i][j] = val; } } np = n; vector<int> I(n); iota(I.begin(), I.end(), 0); Solve(I, 1, n); for(int i = 0; i < n; i++) P[i] = ans[i]; } /* 4 1 6 6 5 3 2 1 6 4 */

컴파일 시 표준 에러 (stderr) 메시지

koala.cpp: In function 'void Solve(std::vector<int>, int, int)':
koala.cpp:35:9: warning: unused variable 'n' [-Wunused-variable]
   35 |     int n = np;
      |         ^
#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...