답안 #1028558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028558 2024-07-20T04:31:51 Z vjudge1 코알라 (APIO17_koala) C++17
60 / 100
60 ms 472 KB
#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(243987);
int minValue(int N, int W) {
    int me[100]{1},you[100];
    playRound(me,you);
    for(int i=0;i<N;i++)
        if(you[i]==0)
            return i;
    return 0;
}

int maxValue(int N, int W) {
    int me[100],you[100];
    vector<int>theposs(N);
    iota(theposs.begin(),theposs.end(),0);
    while(theposs.size()>1){
        memset(me,0,sizeof me);
        for(auto i:theposs)
            me[i]=W/theposs.size();
        playRound(me,you);
        vector<int>theposs2;
        for(auto i:theposs)
            if(you[i])theposs2.push_back(i);
        theposs=theposs2;
    }
    return theposs[0];
}
int maxValue2(set<int>theposs, int W) {
    int me[100],you[100], ORIG=theposs.size();
    while(theposs.size()>1){
        memset(me,0,sizeof me);
        for(auto i:theposs)
            me[i]=(W+theposs.size()-ORIG)/theposs.size();
        playRound(me,you);
        set<int>theposs2;
        for(auto i:theposs)
            if(you[i])theposs2.insert(i);
        theposs=theposs2;
    }
    return *theposs.begin();
}

int greaterValue(int N, int W) {
    int me[100]{1,1},you[100];
    int L=1,R=min(W/2,8);
    while(L<=R){
        int mid=L+R>>1;
        me[0]=mid;
        me[1]=mid;
        playRound(me,you);
        if(you[0]-you[1])
            return !you[0];
        if(you[0])
            L=mid+1;
        else R=mid-1;
    }
}

int greaterValue2(int A,int B) {
    int me[100]{},you[100];
    int L=2,R=8;
    while(L<=R){
        int mid=L+R>>1;
        me[A]=mid;
        me[B]=mid;
        playRound(me,you);
        if(you[A]-you[B])
            return !you[A];
        if(you[A])
            L=mid+1;
        else R=mid-1;
    }
    me[A]=1,me[B]=1;
    playRound(me,you);
    return !you[A];
}
vector<int>mergesort(vector<int>a){
    if(a.size()==1) return a;
    vector<int>a2,b2;
    shuffle(a.begin(),a.end(),rng);
    for(int i=0;i<a.size()/2;i++)
        a2.push_back(a[i]);
    for(int i=a.size()/2;i<a.size();i++)
        b2.push_back(a[i]);
    a2=mergesort(a2);
    b2=mergesort(b2);
    vector<int>finals;
    int l=0,r=0;
    while(l<a2.size()&&r<b2.size()){
        if(greaterValue2(a2[l],b2[r])) {
            finals.push_back(b2[r++]);
        } else {
            finals.push_back(a2[l++]);
        }
    }
    while(l<a2.size())
        finals.push_back(a2[l++]);
    while(r<b2.size())
        finals.push_back(b2[r++]);
    return finals;
}
void allValues(int N, int W, int *P) {
    vector<int>v(N);
    iota(v.begin(),v.end(),0);
    v=mergesort(v);
    for(int i=0;i<N;i++)
        P[v[i]]=N-i;
}

Compilation message

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:49:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |         int mid=L+R>>1;
      |                 ~^~
koala.cpp: In function 'int greaterValue2(int, int)':
koala.cpp:65:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   65 |         int mid=L+R>>1;
      |                 ~^~
koala.cpp: In function 'std::vector<int> mergesort(std::vector<int>)':
koala.cpp:83:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for(int i=0;i<a.size()/2;i++)
      |                 ~^~~~~~~~~~~
koala.cpp:85:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for(int i=a.size()/2;i<a.size();i++)
      |                          ~^~~~~~~~~
koala.cpp:91:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |     while(l<a2.size()&&r<b2.size()){
      |           ~^~~~~~~~~~
koala.cpp:91:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |     while(l<a2.size()&&r<b2.size()){
      |                        ~^~~~~~~~~~
koala.cpp:98:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |     while(l<a2.size())
      |           ~^~~~~~~~~~
koala.cpp:100:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |     while(r<b2.size())
      |           ~^~~~~~~~~~
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 9 ms 460 KB Output is correct
3 Correct 9 ms 344 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 47 ms 464 KB Output is partially correct
2 Partially correct 60 ms 468 KB Output is partially correct
3 Partially correct 45 ms 344 KB Output is partially correct
4 Partially correct 45 ms 344 KB Output is partially correct
5 Partially correct 53 ms 344 KB Output is partially correct
6 Partially correct 47 ms 344 KB Output is partially correct
7 Partially correct 45 ms 344 KB Output is partially correct
8 Partially correct 46 ms 472 KB Output is partially correct
9 Partially correct 47 ms 344 KB Output is partially correct
10 Partially correct 44 ms 344 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 21 ms 340 KB Output is partially correct
2 Partially correct 19 ms 460 KB Output is partially correct
3 Partially correct 22 ms 344 KB Output is partially correct
4 Partially correct 19 ms 464 KB Output is partially correct
5 Partially correct 19 ms 344 KB Output is partially correct
6 Partially correct 19 ms 344 KB Output is partially correct
7 Partially correct 19 ms 344 KB Output is partially correct
8 Partially correct 19 ms 344 KB Output is partially correct
9 Partially correct 19 ms 344 KB Output is partially correct
10 Partially correct 21 ms 344 KB Output is partially correct
11 Partially correct 19 ms 344 KB Output is partially correct
12 Partially correct 17 ms 344 KB Output is partially correct
13 Partially correct 19 ms 464 KB Output is partially correct
14 Partially correct 19 ms 344 KB Output is partially correct
15 Partially correct 19 ms 344 KB Output is partially correct
16 Partially correct 19 ms 464 KB Output is partially correct
17 Partially correct 19 ms 344 KB Output is partially correct
18 Partially correct 19 ms 456 KB Output is partially correct
19 Partially correct 20 ms 460 KB Output is partially correct
20 Partially correct 19 ms 464 KB Output is partially correct
21 Partially correct 19 ms 344 KB Output is partially correct
22 Partially correct 19 ms 344 KB Output is partially correct
23 Partially correct 23 ms 340 KB Output is partially correct
24 Partially correct 21 ms 340 KB Output is partially correct
25 Partially correct 19 ms 460 KB Output is partially correct
26 Partially correct 19 ms 344 KB Output is partially correct
27 Partially correct 19 ms 344 KB Output is partially correct
28 Partially correct 19 ms 464 KB Output is partially correct
29 Partially correct 24 ms 344 KB Output is partially correct
30 Partially correct 21 ms 344 KB Output is partially correct
31 Partially correct 19 ms 344 KB Output is partially correct
32 Partially correct 21 ms 344 KB Output is partially correct
33 Partially correct 19 ms 344 KB Output is partially correct
34 Partially correct 19 ms 344 KB Output is partially correct
35 Partially correct 19 ms 344 KB Output is partially correct
36 Partially correct 19 ms 460 KB Output is partially correct
37 Partially correct 20 ms 344 KB Output is partially correct
38 Partially correct 19 ms 344 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