Submission #775471

#TimeUsernameProblemLanguageResultExecution timeMemory
775471vjudge1Koala Game (APIO17_koala)C++17
37 / 100
79 ms368 KiB
#include "koala.h" #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pbds tree<pair<ll, ll>, null_type, less<pair<ll,ll>>,rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1}; int dy[8] = {0, 1, -1, 0, 1, -1, -1, 1}; #define endl "\n" #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } const int mx = 105; int B[mx], R[mx]; /* int secret[mx]; int n; void playRound(int *B, int *R){ int W = n; vii v; for(int i = 0; i < n;i++){ //cout << B[i] << " "; v.pb({secret[i], i}); } //cout << endl; sort(all(v), greater<pii>()); for(int i = 0; W > 0 && i < n;i++){ int ind = v[i].ss; if(W >= B[ind]+1){ W -= B[ind]+1; R[ind] = B[ind]+1; } else break; } for(int i = 0; i < n;i++){ cout << R[i] << " "; } cout << endl; }*/ int minValue(int n, int W) { B[0] = 1; playRound(B, R); for(int i = 1; i < n;i++){ if(R[i] == 0)return i; } return 0; } int maxValue(int n, int W) { set<int> possible; for(int i = 0; i < n;i++){ possible.insert(i); } while(possible.size() > 1){ memset(R, 0, sizeof R); memset(B, 0, sizeof B); int k = W / possible.size(); for(int x : possible){ B[x] = k; } playRound(B, R); int l = 0; for(int i = 0; i < n;i++){ l = max(l, R[i]); } for(int i = 0; i < n;i++){ if(R[i] != l)possible.erase(i); } } return (*possible.begin()); } int greaterValue(int N, int W) { int l = 1, r = 14; while(l <= r){ int md = (l+r)/2; memset(R, 0, sizeof R); B[0] = B[1] = md; playRound(B, R); if(R[0] > R[1])return 0; if(R[1] > R[0])return 1; if(R[0] == 0){ r = md-1; } else{ l = md+1; } } return 0; } bool vis[mx]; 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 { int cur = n; memset(vis, 0, sizeof vis); int tot = W; while(cur >= 1){ set<int> possible; for(int i = 0; i < n;i++){ if(vis[i])continue; possible.insert(i); } while(possible.size() > 1){ memset(R, 0, sizeof R); memset(B, 0, sizeof B); int k = tot / possible.size(); for(int x : possible){ B[x] = k; } playRound(B, R); int l = 0; for(int i = 0; i < n;i++){ if(vis[i])continue; l = max(l, R[i]); } for(int i = 0; i < n;i++){ if(vis[i])continue; if(R[i] != l)possible.erase(i); } } P[(*possible.begin())] = cur; vis[(*possible.begin())] = 1; tot--; cur--; } } } //int P[mx]; /* void run_case(){ n = 10; secret[0] = 2; secret[1] = 1; secret[2] = 3; secret[3] = 5; secret[4] = 7; secret[5] = 4; secret[6] = 8; secret[7] = 6; secret[8] = 9; secret[9] = 10; allValues(10, 10, P); for(int i = 0; i < 10;i++){ cout << P[i] << " "; } cout << endl; } int main(){ init(); speed; int t; //cin >> t; t = 1; while(t--){ run_case(); } }*/

Compilation message (stderr)

koala.cpp: In function 'void init()':
koala.cpp:34:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:36:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...