제출 #1075347

#제출 시각아이디문제언어결과실행 시간메모리
1075347Cyanberry코알라 (APIO17_koala)C++14
4 / 100
75 ms452 KiB
#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] *= 2; ++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 2; } 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) { 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; } } lowerIndex = N - upperIndex - 2; for (int i = 0; i < N; ++i) { play[i] = 0; } for (int i = 0; i < lowerIndex; ++i) { play[i] = 1; } for (int i = upperIndex; i < N; ++i) { play[i] = 1; } while (upperIndex < N) { playRound(play, result); for (int j = 0; j < N; ++j) { if (P[j] > 0) continue; if (result[j] <= comp[j]) { P[j] = upperIndex; ++upperIndex; --lowerIndex; } } play[lowerIndex] = 0; play[upperIndex - 1] = 0; } for (int i = 0; i < N; ++i) { if (P[i] == 0) P[i] = N; } } }

컴파일 시 표준 에러 (stderr) 메시지

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:176:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  176 |                     if (playFrom >= upper.size()) break;
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:179:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  179 |                         if (playFrom >= upper.size()) break;
      |                             ~~~~~~~~~^~~~~~~~~~~~~~~
koala.cpp:187:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  187 |         for (int i = 0; i < lower.size(); ++i) {
      |                         ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...