Submission #1075376

# Submission time Handle Problem Language Result Execution time Memory
1075376 2024-08-26T04:49:55 Z Cyanberry Koala Game (APIO17_koala) C++14
11 / 100
25 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

#include "koala.h"

int perm[] = {5, 3, 2, 1, 6, 4};

int minValue(int N, int W) {
    int play[100], result[100];
    for (int i = 0; i<100; ++i) {
        play[i] = 0;
    }
    play[0] = 1;
    playRound(play, result);
    for (int i = 0; i < 100; ++i) {
        if (result[i] <= play[i]) {
            return i;
        }
    }
    return 0;
}

int maxValue(int N, int W) {
    int play[N], result[N];
    for (int i = 0; i < N; ++i) {
        play[i] = 1;
    }
    playRound(play, result);
    int eep = 100;
    while (eep > 1)
    {
        eep = 0;
        for (int i = 0; i < N; ++i) {
            if (result[i] > 1) {
                play[i] += 1;
                ++eep;
            } else {
                play[i] = 0;
            }
        }
        playRound(play, result);
    }
    for (int i = 0; i < N; ++i) {
        if (play[i] > 0) {
            return i;
        }
    }
    return 0;
}

int greaterValue(int N, int W) {
    int play[N], result[N];
    for (int i = 0; i < N; ++i) {
        play[i] = 0;
    }
    play[0] = 4;
    play[1] = 4;
    playRound(play, result);
    if (result[0] != result[1]) {
        return result[1] > result[0];
    }
    if (result[0] == 0) {
        play[0] = 2;
        play[1] = 2;
        playRound(play, result);
        if (result[0] != result[1]) {
            return result[1] > result[0];
        }
        play[0] = 1;
        play[1] = 1;
        playRound(play, result);
        if (result[0] != result[1]) {
            return result[1] > result[0];
        }
    } else {
        play[0] = 8;
        play[1] = 8;
        if (result[0] != result[1]) {
            return result[1] > result[0];
        }
        play[0] = 6;
        play[1] = 6;
        if (result[0] != result[1]) {
            return result[1] > result[0];
        }
    }
    
    return 0;
}

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 {
        vector<bool> done(N, false);
        int playFrom = 1;
        int play[N], result[N], comp[N];
        for (int i = 0; i<N; ++i) {
            play[i] = 1;
        }
        for (int i = 0; i < N; ++i) {
            P[i] = 0;
        }
        playRound(play, result);
        bool isUpper[N];
        vector<int> upper, lower;
        for (int i = 0; i < N; ++i) {
            if (result[i] < play[i]) {
                isUpper[i] = false;
                lower.push_back(i);
            } else {
                isUpper[i] = true;
                upper.push_back(i);
            }
        }
        int lowerIndex = 1, upperIndex = N/2 + 1;
        for (int i = 0; i<N; ++i) {
            play[i] = 0;
        }
        play[upper[0]] = 1;
        for (int i = 0; i < N/2; ++i) {
            playRound(play, result);
            for (int j = 0; j < N; ++j) {
                comp[j] = play[j];
            }
            for (int j = 0; j < N; ++j) {
                if (P[j] > 0) continue;
                if (result[j] <= comp[j]) {
                    if (isUpper[j]) {
                        P[j] = upperIndex;
                        ++upperIndex;
                        if (play[j] > 0) {
                            if (playFrom >= upper.size()) break;
                            while(P[upper[playFrom]] > 0) {
                                ++playFrom;
                                if (playFrom >= upper.size()) break;
                                //cout<<P[upper[playFrom]]<<'\n';
                            }
                            ++play[upper[playFrom]];
                            ++playFrom;
                        }
                        play[j] = 0;
                    } else {
                        P[j] = lowerIndex;
                        ++lowerIndex;
                        if (playFrom >= upper.size()) break;
                        while(P[upper[playFrom]] > 0) {
                            ++playFrom;
                            if (playFrom >= upper.size()) break;
                            //cout<<P[upper[playFrom]]<<'\n';
                        }
                        ++play[upper[playFrom]];
                        ++playFrom;
                    }
                }
            }
        }
        while (lowerIndex < N/2)
        {
            cout<<lowerIndex<<'\n';
            for (int i = 0; i < N; ++i) {
                if (P[i] == 1 || P[i] == lowerIndex - 1 || (P[i] == 0 && isUpper[i])) {
                    play[i] = 0;
                } else {
                    play[i] = 1;
                }
            }
            
            playRound(play, result);
            for (int j = 0; j < N; ++j) {
                if (P[j] > 0) continue;
                if (result[j] <= comp[j]) {
                    P[j] = lowerIndex;
                    ++lowerIndex;
                    if (playFrom >= upper.size()) break;
                    while(P[upper[playFrom]] > 0) {
                        ++playFrom;
                        if (playFrom >= upper.size()) break;
                        //cout<<P[upper[playFrom]]<<'\n';
                    }
                    ++play[upper[playFrom]];
                    ++playFrom;
                }
            }
        }
        for (int i = 0; i < lower.size(); ++i) {
            if (P[lower[i]] == 0) {
                P[lower[i]] = lowerIndex;
            }
        }
        for (int i = 0; i<N; ++i) {
            play[i] = 0;
            if (i >= upperIndex) {
                play[i] = 2;
            }
        }
        playRound(play, result);
        bool isUpper1[N];
        vector<int> upper1, lower1;
        for (int i = 0; i < N; ++i) {
            if (result[i] < play[i]) {
                isUpper1[i] = false;
                lower1.push_back(i);
            } else {
                isUpper1[i] = true;
                upper1.push_back(i);
            }
        }
        for (int i = 0; i < N; ++i) {
            if (P[i] > 0) play[i] = 1;
        }
        int upperIndex1 = N - upper1.size() + 1, lowerIndex1 = upperIndex;
        playFrom = 0;
        for (int i = upperIndex; i < upperIndex + lower1.size(); ++i) {
            playRound(play, result);
            for (int j = 0; j < N; ++j) {
                comp[j] = play[j];
            }
            for (int j = 0; j < N; ++j) {
                if (P[j] > 0) continue;
                if (result[j] <= comp[j]) {
                    if (isUpper1[j]) {
                        P[j] = upperIndex1;
                        ++upperIndex1;
                        if (play[j] > 0) {
                            if (playFrom >= upper1.size()) break;
                            while(P[upper[playFrom]] > 0) {
                                ++playFrom;
                                if (playFrom >= upper1.size()) break;
                                //cout<<P[upper[playFrom]]<<'\n';
                            }
                            ++play[upper1[playFrom]];
                            ++playFrom;
                        }
                        play[j] = 0;
                    } else {
                        P[j] = lowerIndex1;
                        ++lowerIndex1;
                        if (playFrom >= upper1.size()) break;
                        while(P[upper1[playFrom]] > 0) {
                            ++playFrom;
                            if (playFrom >= upper1.size()) break;
                            //cout<<P[upper[playFrom]]<<'\n';
                        }
                        ++play[upper1[playFrom]];
                        ++playFrom;
                    }
                }
            }
        }
        while (lowerIndex1 < N - upper1.size())
        {
            for (int i = 0; i < N; ++i) {
                if (P[i] == 1 || P[i] == lowerIndex1 - 1 || (P[i] == 0 && isUpper1[i])) {
                    play[i] = 0;
                } else {
                    play[i] = 1;
                }
            }
            
            playRound(play, result);
            for (int j = 0; j < N; ++j) {
                if (P[j] > 0) continue;
                if (result[j] <= comp[j]) {
                    P[j] = lowerIndex1;
                    ++lowerIndex1;
                    if (playFrom >= upper1.size()) break;
                    while(P[upper[playFrom]] > 0) {
                        ++playFrom;
                        if (playFrom >= upper1.size()) break;
                        //cout<<P[upper[playFrom]]<<'\n';
                    }
                    ++play[upper1[playFrom]];
                    ++playFrom;
                }
            }
        }
        for (int i = 0; i < lower.size(); ++i) {
            if (P[lower[i]] == 0) {
                P[lower[i]] = lowerIndex1;
            }
        }
        int lim = N, rem = 100;
        while (lim > upperIndex1) {
            rem = 100;
            int stones = lim / (lim - upperIndex1);
            for (int i = 0; i < N; ++i) {
                play[i] = 0;
            }
            for (int i = upperIndex1; i < lim; ++i) {
                play[i] = stones;
                rem -= stones;
            }
            rem /= (N + 1) - lim;
            for (int i = lim; i < N; ++i) {
                play[i] = rem;
            }
            playRound(play, result);
            for (int i = upperIndex1; i < N; ++i) {
                if (result[i] > play[i]) {
                    P[i] = lim;
                    --lim;
                }
            }
        }
    }
}


Compilation message

koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:135:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  135 |                             if (playFrom >= upper.size()) break;
      |                                 ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:138:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |                                 if (playFrom >= upper.size()) break;
      |                                     ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:148:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |                         if (playFrom >= upper.size()) break;
      |                             ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:151:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  151 |                             if (playFrom >= upper.size()) break;
      |                                 ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:177:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  177 |                     if (playFrom >= upper.size()) break;
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:180:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  180 |                         if (playFrom >= upper.size()) break;
      |                             ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:188:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  188 |         for (int i = 0; i < lower.size(); ++i) {
      |                         ~~^~~~~~~~~~~~~~
koala.cpp:216:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  216 |         for (int i = upperIndex; i < upperIndex + lower1.size(); ++i) {
      |                                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:228:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  228 |                             if (playFrom >= upper1.size()) break;
      |                                 ~~~~~~~~~^~~~~~~~~~~~~~~~
koala.cpp:231:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  231 |                                 if (playFrom >= upper1.size()) break;
      |                                     ~~~~~~~~~^~~~~~~~~~~~~~~~
koala.cpp:241:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  241 |                         if (playFrom >= upper1.size()) break;
      |                             ~~~~~~~~~^~~~~~~~~~~~~~~~
koala.cpp:244:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  244 |                             if (playFrom >= upper1.size()) break;
      |                                 ~~~~~~~~~^~~~~~~~~~~~~~~~
koala.cpp:253:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  253 |         while (lowerIndex1 < N - upper1.size())
      |                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
koala.cpp:269:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  269 |                     if (playFrom >= upper1.size()) break;
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~~
koala.cpp:272:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  272 |                         if (playFrom >= upper1.size()) break;
      |                             ~~~~~~~~~^~~~~~~~~~~~~~~~
koala.cpp:280:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  280 |         for (int i = 0; i < lower.size(); ++i) {
      |                         ~~^~~~~~~~~~~~~~
# 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 Partially correct 21 ms 344 KB Output is partially correct
2 Partially correct 20 ms 344 KB Output is partially correct
3 Partially correct 25 ms 344 KB Output is partially correct
4 Partially correct 20 ms 344 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -