답안 #775460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775460 2023-07-06T11:59:52 Z YassineBenYounes 코알라 (APIO17_koala) C++17
37 / 100
97 ms 352 KB
#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;

const int mx = 105;

int B[mx], R[mx];

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) {
    /*for(int x = 1; x <= 14;x++){
        B[0] = B[1] = x;
        
        if(R[0] > R[1])return 0;
        else if(R[0] < R[1])return 1;
    }*/
    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 x = 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 = x / 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;
            x--;
            cur--;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 14 ms 328 KB Output is correct
4 Correct 13 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 328 KB Output is correct
2 Correct 38 ms 328 KB Output is correct
3 Correct 36 ms 336 KB Output is correct
4 Correct 35 ms 336 KB Output is correct
5 Correct 37 ms 328 KB Output is correct
6 Correct 34 ms 332 KB Output is correct
7 Correct 34 ms 332 KB Output is correct
8 Correct 34 ms 352 KB Output is correct
9 Correct 34 ms 336 KB Output is correct
10 Correct 34 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 97 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -