Submission #1262035

#TimeUsernameProblemLanguageResultExecution timeMemory
1262035Zbyszek99Koala Game (APIO17_koala)C++20
29 / 100
18 ms440 KiB
#include "koala.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define ull unsigned long long #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vl vector<long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define siz(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; //mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} //ll los(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; int minValue(int N, int W) { int q[N]; rep(i,N) q[i] = 0; q[0] = 1; int ans[N]; playRound(q,ans); rep(i,N) { if(ans[i] <= q[i]) return i; } } int solve(int n, vi p) { if(siz(p) == 1) return p[0]; int k = 0; rep2(kk,1,n) { if(siz(p)*kk > n) break; int s1 = (n-siz(p))*(n-siz(p)+1)/2; int s2 = 0; rep2(i,n-siz(p)+1,n) { if(kk*(i-(n-siz(p))+1) <= n) { s2 = max(s2,i*(i+1)/2); } } if(s2 > s1) { k = kk; } } int q[n]; int ans[n]; rep(i,n) q[i] = 0; forall(it,p) q[it] = k; playRound(q,ans); vi p2; forall(it,p) if(ans[it] > q[it]) p2.pb(it); return solve(n,p2); } int maxValue(int N, int W) { vi p; rep(i,N) p.pb(i); return solve(N,p); } int greaterValue(int N, int W) { // TODO: Implement Subtask 3 solution here. // You may leave this function unmodified if you are not attempting this // subtask. return 0; } int n; bool comp(int a, int b) { int q[n]; int ans[n]; rep(i,n) q[i] = 0; q[a] = n; q[b] = n; playRound(q,ans); if(ans[a] > n) return 0; return 1; } vi merge_sort(vi p) { if(siz(p) == 1) return p; vi l; vi r; rep(i,siz(p)/2) l.pb(p[i]); rep2(i,siz(p)/2,siz(p)-1) r.pb(p[i]); l = merge_sort(l); r = merge_sort(r); vi ans; int cur_l = 0; int cur_r = 0; while(cur_l < siz(l) || cur_r < siz(r)) { if(cur_l == siz(l)) ans.pb(r[cur_r++]); else if(cur_r == siz(r)) ans.pb(l[cur_l++]); else { if(comp(l[cur_l],r[cur_r])) ans.pb(l[cur_l++]); else ans.pb(r[cur_r++]); } } return ans; } void allValues(int N, int W, int *P) { n = N; if (W == 2*N) { vi p; rep(i,N) p.pb(i); p = merge_sort(p); rep(i,N) { P[p[i]] = i+1; } } else { // TODO: Implement Subtask 5 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } }

Compilation message (stderr)

koala.cpp: In function 'int minValue(int, int)':
koala.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
#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...