Submission #899304

# Submission time Handle Problem Language Result Execution time Memory
899304 2024-01-05T17:16:50 Z AdamGS Koala Game (APIO17_koala) C++17
66 / 100
58 ms 600 KB
#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
int minValue(int N, int W) {
  int P[N], T[N];
  rep(i, N) P[i]=0;
  P[0]=1;
  playRound(P, T);
  rep(i, N) if(P[i]>=T[i]) return i;
  return 0;
}

int maxValue(int N, int W) {
  int P[N], T[N];
  vector<int>V(N);
  rep(i, N) V[i]=0;
  int ans=-1;
  while(true) {
    int ile=N;
    rep(i, N) if(V[i]) --ile;
    if(ile==1) {
      rep(i, N) if(!V[i]) ans=i;
      break;
    }
    rep(i, N) if(V[i]) P[i]=0; else P[i]=W/ile;
    playRound(P, T);
    rep(i, N) if(P[i]>=T[i]) V[i]=1;
    int ans=0;
    rep(i, N) if(!V[i]) ++ans;
  }
  return ans;
}

int greaterValue(int N, int W) {
  int P[N], T[N], po=1, ko=8;
  rep(i, N) P[i]=0;
  while(po<ko) {
    int sr=(po+ko)/2;
    P[0]=P[1]=sr;
    playRound(P, T);
    if(T[0]>sr && T[1]<=sr) return 0;
    if(T[0]<=sr && T[1]>sr) return 1;
    if(T[0]>sr) po=sr+1; else ko=sr-1;
  }
  P[0]=P[1]=po;
  playRound(P, T);
  if(T[0]<=po) return 1;
  return 0;
}

bool comp(int a, int b) {
  int P[100], T[100];
  rep(i, 100) P[i]=0;
  P[a]=P[b]=100;
  playRound(P, T);
  if(T[a]<=P[a]) return true;
  return false;
}

bool comp2(int a, int b) {
  int N=100;
  int P[N], T[N], po=1, ko=8;
  rep(i, N) P[i]=0;
  while(po<ko) {
    int sr=(po+ko)/2;
    P[a]=P[b]=sr;
    playRound(P, T);
    if(T[a]>sr && T[b]<=sr) return 0;
    if(T[a]<=sr && T[b]>sr) return 1;
    if(T[a]>sr) po=sr+1; else ko=sr-1;
  }
  P[a]=P[b]=po;
  playRound(P, T);
  if(T[a]<=po) return 1;
  return 0;
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
      int T[N];
      rep(i, N) T[i]=i;
      stable_sort(T, T+N, comp);
      rep(i, N) P[T[i]]=i+1;
    } else {
      int T[N];
      rep(i, N) T[i]=i;
      stable_sort(T, T+N, comp2);
      rep(i, N) P[T[i]]=i+1;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 500 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 10 ms 344 KB Output is correct
4 Correct 10 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 51 ms 480 KB Output is partially correct
2 Partially correct 58 ms 468 KB Output is partially correct
3 Partially correct 47 ms 452 KB Output is partially correct
4 Partially correct 46 ms 344 KB Output is partially correct
5 Partially correct 48 ms 484 KB Output is partially correct
6 Partially correct 48 ms 480 KB Output is partially correct
7 Partially correct 48 ms 468 KB Output is partially correct
8 Partially correct 52 ms 460 KB Output is partially correct
9 Partially correct 47 ms 468 KB Output is partially correct
10 Partially correct 46 ms 480 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 344 KB Output is correct
2 Correct 28 ms 344 KB Output is correct
3 Correct 28 ms 344 KB Output is correct
4 Correct 27 ms 428 KB Output is correct
5 Correct 27 ms 344 KB Output is correct
6 Correct 27 ms 344 KB Output is correct
7 Correct 27 ms 344 KB Output is correct
8 Correct 28 ms 344 KB Output is correct
9 Correct 28 ms 344 KB Output is correct
10 Correct 26 ms 448 KB Output is correct
11 Correct 28 ms 452 KB Output is correct
12 Correct 12 ms 344 KB Output is correct
13 Correct 26 ms 344 KB Output is correct
14 Correct 24 ms 344 KB Output is correct
15 Correct 24 ms 344 KB Output is correct
16 Correct 25 ms 344 KB Output is correct
17 Correct 24 ms 344 KB Output is correct
18 Correct 24 ms 344 KB Output is correct
19 Correct 25 ms 344 KB Output is correct
20 Correct 25 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 19 ms 448 KB Output is partially correct
2 Partially correct 27 ms 340 KB Output is partially correct
3 Partially correct 27 ms 344 KB Output is partially correct
4 Partially correct 28 ms 344 KB Output is partially correct
5 Partially correct 27 ms 344 KB Output is partially correct
6 Partially correct 27 ms 344 KB Output is partially correct
7 Partially correct 26 ms 452 KB Output is partially correct
8 Partially correct 30 ms 344 KB Output is partially correct
9 Partially correct 26 ms 448 KB Output is partially correct
10 Partially correct 26 ms 344 KB Output is partially correct
11 Partially correct 26 ms 344 KB Output is partially correct
12 Partially correct 11 ms 452 KB Output is partially correct
13 Partially correct 25 ms 344 KB Output is partially correct
14 Partially correct 26 ms 452 KB Output is partially correct
15 Partially correct 26 ms 344 KB Output is partially correct
16 Partially correct 26 ms 344 KB Output is partially correct
17 Partially correct 27 ms 344 KB Output is partially correct
18 Partially correct 26 ms 344 KB Output is partially correct
19 Partially correct 27 ms 344 KB Output is partially correct
20 Partially correct 26 ms 344 KB Output is partially correct
21 Partially correct 26 ms 344 KB Output is partially correct
22 Partially correct 28 ms 452 KB Output is partially correct
23 Partially correct 25 ms 600 KB Output is partially correct
24 Partially correct 26 ms 540 KB Output is partially correct
25 Partially correct 25 ms 344 KB Output is partially correct
26 Partially correct 27 ms 344 KB Output is partially correct
27 Partially correct 26 ms 344 KB Output is partially correct
28 Partially correct 27 ms 432 KB Output is partially correct
29 Partially correct 26 ms 344 KB Output is partially correct
30 Partially correct 28 ms 504 KB Output is partially correct
31 Partially correct 26 ms 344 KB Output is partially correct
32 Partially correct 26 ms 344 KB Output is partially correct
33 Partially correct 26 ms 452 KB Output is partially correct
34 Partially correct 23 ms 344 KB Output is partially correct
35 Partially correct 27 ms 344 KB Output is partially correct
36 Partially correct 26 ms 344 KB Output is partially correct
37 Partially correct 24 ms 452 KB Output is partially correct
38 Partially correct 25 ms 344 KB Output is partially correct
39 Partially correct 24 ms 448 KB Output is partially correct
40 Partially correct 30 ms 440 KB Output is partially correct