Submission #960844

# Submission time Handle Problem Language Result Execution time Memory
960844 2024-04-11T06:17:37 Z AlperenT_ Koala Game (APIO17_koala) C++14
100 / 100
51 ms 624 KB
#include "koala.h"
#include <bits/stdc++.h>

#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second 
#define ld long double
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
#define deb(x) cout <<#x << " : " << x << "\n" ;
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 5e5+10 , maxk = 1e4, sq = 1e5 , lg = 19,  inf = 1e9+10 , mod = 31607;
int B[maxn] , R[maxn] ;
int minValue(int N, int W) {
    int a[N] , b[N] ;
    rep(i , 0 , N-2){
        a[i] =0 ;
    }
    a[N-1] = 1;
    playRound(a,b) ;
    rep(i , 0 , N-2){
        if(b[i] == 0)return i ;
    }
    return N-1 ; 
}

int maxValue(int n, int w) {
    vector <int> vec;
    rep(i , 0 , n-1)vec.pb(i) ;
    while(sz(vec)!=1){
        int a[n] , b[n] ;
        int x =min(13 ,w/sz(vec)) ;
        rep(i ,0  ,n-1)a[i] = 0; 
        rep(i , 0 , sz(vec)-1){
            a[vec[i]] = x; 
        }
        playRound(a,b) ;
        vec.clear();
        rep(i , 0 , n-1)if(a[i] > 0 && b[i] > a[i])vec.pb(i) ;
    }
    return vec[0];
}
int greaterValue(int n, int W){
	int low=1,high=min(10,W/2);
	while(low<=high){
		int mid=(low+high)/2;
		int a[n],b[n];
		for(int i=0;i<n;i++) a[i]=0;
		a[0]=a[1]=mid;
		playRound(a,b);
		if(b[0]>mid&&b[1]>mid) low=mid+1;
		else if(b[0]<=mid&&b[1]<=mid) high=mid-1;
		else return (b[0]>mid?0:1);
	}
	return 0;
}
int n ; 
bool cmp1(int A ,int B){
    int a[n] , b[n];
    rep(i , 0 , n-1)a[i] =0 ;
    a[A] = 100 ;
    a[B] = 100 ;
    playRound(a,b); 
    if(b[A] > b[B])return 0 ;
    return 1 ;  
}
vector <int> mrg(vector <int> vec){
    if(sz(vec)==1)return vec;
    int mid = (sz(vec))/2 ;
    vector <int> a, b; 
    rep(i, 0 , mid-1){
        a.pb(vec[i]) ;
    }
    rep(i , mid , sz(vec)-1){
        b.pb(vec[i]) ;
    }
    a = mrg(a) ;
    b = mrg(b);
    vec.clear() ;
    int i1 =0 , i2= 0 ;
    while(i1 < sz(a) || i2 < sz(b)){
        if(i1 < sz(a) && (i2==sz(b) || cmp1(a[i1] , b[i2]) == 1)){
            vec.pb(a[i1]);i1++;
        }else{
            vec.pb(b[i2]);i2++;
        }
    }
    return vec;
}
vector <int> bui(vector <int> vec , int l = 1 , int r = 100){
    if(sz(vec)==1)return vec; 
    int a[n] , b[n];
    rep(i , 0 , n-1)a[i] =0 ;
    int w=  min((int)sqrt(2*l) , 100/sz(vec)) ;
    for(int x : vec)a[x] = w ;
    playRound(a,b);
    vector <int> h , o ;
    for(int x : vec){
        if(b[x] > a[x])h.pb(x);
        else o.pb(x);
    }
    h =bui(h , l+sz(o) , r);
    o = bui(o , l , l+sz(o)-1);
    vec.clear();
    vec = o;
    for(int x : h)vec.pb(x);
    return vec ;
}

void allValues(int N, int W, int *p) {
    n  = N ;
    if (W == 2*N) {
        vector <int> vec; 
        rep(i , 0 , n-1)vec.pb(i) ;
        vec= mrg(vec) ;
        rep(i , 0 ,n-1){
            p[vec[i]]=i+1 ; 
        }
    } else {
        vector <int> vec; 
        rep(i , 0 , n-1)vec.pb(i) ;
        vec= bui(vec) ;
        rep(i , 0 ,n-1){
            p[vec[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 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 624 KB Output is correct
2 Correct 10 ms 464 KB Output is correct
3 Correct 10 ms 464 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 484 KB Output is correct
2 Correct 46 ms 488 KB Output is correct
3 Correct 43 ms 600 KB Output is correct
4 Correct 39 ms 488 KB Output is correct
5 Correct 39 ms 500 KB Output is correct
6 Correct 49 ms 492 KB Output is correct
7 Correct 39 ms 480 KB Output is correct
8 Correct 41 ms 512 KB Output is correct
9 Correct 51 ms 488 KB Output is correct
10 Correct 41 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 340 KB Output is correct
2 Correct 26 ms 344 KB Output is correct
3 Correct 26 ms 540 KB Output is correct
4 Correct 25 ms 476 KB Output is correct
5 Correct 24 ms 352 KB Output is correct
6 Correct 25 ms 472 KB Output is correct
7 Correct 24 ms 344 KB Output is correct
8 Correct 24 ms 344 KB Output is correct
9 Correct 25 ms 600 KB Output is correct
10 Correct 24 ms 344 KB Output is correct
11 Correct 24 ms 344 KB Output is correct
12 Correct 16 ms 468 KB Output is correct
13 Correct 24 ms 344 KB Output is correct
14 Correct 24 ms 504 KB Output is correct
15 Correct 22 ms 344 KB Output is correct
16 Correct 22 ms 344 KB Output is correct
17 Correct 22 ms 464 KB Output is correct
18 Correct 22 ms 344 KB Output is correct
19 Correct 22 ms 468 KB Output is correct
20 Correct 27 ms 460 KB Output is correct
# 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 3 ms 344 KB Output is correct
4 Correct 3 ms 500 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 3 ms 356 KB Output is correct
11 Correct 3 ms 352 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 352 KB Output is correct
17 Correct 3 ms 352 KB Output is correct
18 Correct 4 ms 428 KB Output is correct
19 Correct 3 ms 356 KB Output is correct
20 Correct 4 ms 352 KB Output is correct
21 Correct 3 ms 352 KB Output is correct
22 Correct 3 ms 352 KB Output is correct
23 Correct 3 ms 356 KB Output is correct
24 Correct 3 ms 488 KB Output is correct
25 Correct 3 ms 608 KB Output is correct
26 Correct 4 ms 352 KB Output is correct
27 Correct 3 ms 348 KB Output is correct
28 Correct 3 ms 356 KB Output is correct
29 Correct 3 ms 484 KB Output is correct
30 Correct 3 ms 356 KB Output is correct
31 Correct 3 ms 356 KB Output is correct
32 Correct 3 ms 356 KB Output is correct
33 Correct 3 ms 356 KB Output is correct
34 Correct 3 ms 356 KB Output is correct
35 Correct 3 ms 544 KB Output is correct
36 Correct 4 ms 480 KB Output is correct
37 Correct 3 ms 340 KB Output is correct
38 Correct 3 ms 344 KB Output is correct
39 Correct 3 ms 344 KB Output is correct
40 Correct 3 ms 344 KB Output is correct