Submission #1040354

# Submission time Handle Problem Language Result Execution time Memory
1040354 2024-08-01T01:53:08 Z Saul0906 Koala Game (APIO17_koala) C++14
60 / 100
36 ms 600 KB
#include <bits/stdc++.h>
#include "koala.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("popcnt")
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int,int>;
using pll = pair<ll, ll>;
using vii = vector<ii>;
using vpll = vector<pll>;
 
#define endl '\n'
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
 
#define fore(i,l,r) for(auto i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(auto i=r; i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)
 
bool cmin(int &a, int b){if(b<a){a=b;return 1;}return 0;}
bool cmax(int &a, int b){if(b>a){a=b;return 1;}return 0;}
void valid(ll in){cout<<((in)?"YES\n":"NO\n");}
ll lcm(ll a, ll b){return (a/gcd(a,b))*b;}
ll gauss(ll n){return (n*(n+1))/2;}
const int N = 100;
int B[N], R[N], WW;
int minValue(int N, int W) {
    fo(i,N)B[i]=0,R[i]=0;
    fo(i,N){
        B[i]=1;
        playRound(B,R);
        int mx=0;
        fo(j,N)mx = max(mx, R[j]);
        fo(j,N)if(R[j]==0)return j;
        if(mx==1)return i;
        assert(0);
        B[i]=0;
    }
    return 0;
}
int maxValue(int N, int W) {
    fo(i,N)B[i]=R[i]=0;
    fo(i,N)B[i]=1;
    playRound(B,R);
    fo(i,N)B[i]=0;
    fo(i,N)if(R[i]>1)B[i]=2;
    fo(i,N)R[i]=0;
    playRound(B,R);
    fo(i,N)B[i]=0;
    fo(i,N)if(R[i]>2)B[i]=4;
    fo(i,N)R[i]=0;
    playRound(B,R);
    fo(i,N)B[i]=0;
    fo(i,N)if(R[i]>4)B[i]=11;
    fo(i,N)R[i]=0;
    playRound(B,R);
 	fo(i,N)if(R[i]>11)return i;
    // return ans;
}
 
int greaterValue2(int N, int W, int x, int y) {
    int l=1,r=10;
    while(l<=r){
        int m=(l+r)/2;
        fo(i,N)B[i]=R[i]=0;
        B[x]=B[y]=m;
        playRound(B, R);
        if(R[x]>m&&R[y]<=m)return 0;
        if(R[y]>m&&R[x]<=m)return 1;
        if(R[x]>m&&R[y]>m)l=m+1;
        else r=m-1;
    }
    assert(0);
    return 0;
}
int greaterValue(int N, int W){
  return greaterValue2(N,W,0,1);
} 
bool ord(int i, int j){
    return greaterValue2(N,WW,i,j);
}
void allValues(int N, int W, int *P) {
    WW=W;
    // if (W == 2*N) {
        int xd[N];
        fo(i,N)xd[i]=i;
        sort(xd,xd+N,ord);
        fo(i,N)P[xd[i]]=i+1;
    // } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    // }
}
 
// void test_case(){
//     cin >> N >> W;
//     int B[N], R[N];
//     fo(i,N)B[i]=R[i]=0;
//     fo(i,N)P[i]=i+1;
//     fore(i,91,N)B[i]=16;
//     playRound(B,R);
//     fo(i,N)cout<<R[i]<<" ";
//     cout<<endl;
// }
// int main(){cin.tie(0)->sync_with_stdio(0);
//     int t=1;
//     // cin >> t;
//     while(t--)test_case();
// }

Compilation message

koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 8 ms 344 KB Output is correct
4 Correct 8 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 468 KB Output is correct
2 Correct 35 ms 344 KB Output is correct
3 Correct 33 ms 340 KB Output is correct
4 Correct 30 ms 344 KB Output is correct
5 Correct 32 ms 484 KB Output is correct
6 Correct 31 ms 344 KB Output is correct
7 Correct 31 ms 344 KB Output is correct
8 Correct 32 ms 464 KB Output is correct
9 Correct 31 ms 344 KB Output is correct
10 Correct 36 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 20 ms 452 KB Output is partially correct
2 Partially correct 23 ms 344 KB Output is partially correct
3 Partially correct 21 ms 344 KB Output is partially correct
4 Partially correct 21 ms 344 KB Output is partially correct
5 Partially correct 28 ms 348 KB Output is partially correct
6 Partially correct 22 ms 348 KB Output is partially correct
7 Partially correct 22 ms 456 KB Output is partially correct
8 Partially correct 23 ms 452 KB Output is partially correct
9 Partially correct 24 ms 340 KB Output is partially correct
10 Partially correct 20 ms 452 KB Output is partially correct
11 Partially correct 22 ms 348 KB Output is partially correct
12 Partially correct 14 ms 452 KB Output is partially correct
13 Partially correct 22 ms 348 KB Output is partially correct
14 Partially correct 24 ms 348 KB Output is partially correct
15 Partially correct 20 ms 348 KB Output is partially correct
16 Partially correct 23 ms 348 KB Output is partially correct
17 Partially correct 25 ms 448 KB Output is partially correct
18 Partially correct 24 ms 344 KB Output is partially correct
19 Partially correct 23 ms 344 KB Output is partially correct
20 Partially correct 22 ms 452 KB Output is partially correct
21 Partially correct 21 ms 344 KB Output is partially correct
22 Partially correct 23 ms 452 KB Output is partially correct
23 Partially correct 18 ms 344 KB Output is partially correct
24 Partially correct 23 ms 344 KB Output is partially correct
25 Partially correct 22 ms 344 KB Output is partially correct
26 Partially correct 23 ms 344 KB Output is partially correct
27 Partially correct 22 ms 344 KB Output is partially correct
28 Partially correct 22 ms 344 KB Output is partially correct
29 Partially correct 21 ms 456 KB Output is partially correct
30 Partially correct 22 ms 452 KB Output is partially correct
31 Partially correct 22 ms 344 KB Output is partially correct
32 Partially correct 24 ms 344 KB Output is partially correct
33 Partially correct 22 ms 448 KB Output is partially correct
34 Partially correct 23 ms 344 KB Output is partially correct
35 Partially correct 22 ms 344 KB Output is partially correct
36 Partially correct 21 ms 452 KB Output is partially correct
37 Partially correct 22 ms 344 KB Output is partially correct
38 Partially correct 21 ms 340 KB Output is partially correct
39 Partially correct 22 ms 344 KB Output is partially correct
40 Partially correct 21 ms 344 KB Output is partially correct