Submission #409250

#TimeUsernameProblemLanguageResultExecution timeMemory
409250cheissmartKoala Game (APIO17_koala)C++14
24 / 100
144 ms448 KiB
#ifndef CHEISSMART #include "koala.h" #endif #include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define MP make_pair #define EB emplace_back #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m"; void DBG() { cerr << "]" << _reset << endl; } template<class H, class...T> void DBG(H h, T ...t) { cerr << to_string(h); if(sizeof ...(t)) cerr << ", "; DBG(t...); } #ifdef CHEISSMART #define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) #else #define debug(...) #endif const int INF = 1e9 + 7; int a[100], b[100]; int minValue(int N, int W) { for(int i = 0; i < N; i++) a[i] = 1; playRound(a, b); int k; for(int j = 0; j < N; j++) if(b[j] == 2) k = j; for(int i = 0; i < N; i++) a[i] = 0; a[k] = 1; playRound(a, b); for(int i = 0; i < N; i++) if(b[i] == 0) return i; } int maxValue(int N, int W) { set<int> s; for(int i = 0; i < N; i++) s.insert(i); while(s.size() > 1) { int x = s.size(); for(int i = 0; i < N; i++) { if(s.count(i)) { a[i] = W / x; } else { a[i] = 0; } } s.clear(); playRound(a, b); for(int i = 0; i < N; i++) if(b[i] == W / x + 1) s.insert(i); } return *s.begin(); } int greaterValue(int N, int W) { int mn = minValue(N, W); if(mn == 0) return 1; else if(mn == 1) return 0; int lb = 1, rb = 8; while(true) { for(int i = 0; i < N; i++) a[i] = 0; int mb = (lb + rb) / 2; debug(lb, mb, rb); a[0] = a[1] = mb; playRound(a, b); if(b[0] > a[0] && b[1] <= a[1]) return 0; if(b[1] > a[1] && b[0] <= a[0]) return 1; if(b[0] > a[0] && b[1] > a[1]) lb = mb + 1; else rb = mb - 1; } } void allValues(int N, int W, int *P) { if (W == 2*N) { // TODO: Implement Subtask 4 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } 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:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
koala.cpp:47:10: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |     a[k] = 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...