Submission #408984

#TimeUsernameProblemLanguageResultExecution timeMemory
408984syl123456Koala Game (APIO17_koala)C++17
37 / 100
93 ms336 KiB
#include "koala.h" #include <bits/stdc++.h> using namespace std; int minValue(int N, int W) { // TODO: Implement Subtask 1 solution here. // You may leave this function unmodified if you are not attempting this // subtask. int a[N], b[N]; for (int &i : a) i = 1; playRound(a, b); int tmp = 0; for (int i = 0; i < N; ++i) { if (b[i] == 0) a[i] = 0; else if (tmp == 0) a[i] = 98, ++tmp; else if (tmp == 1) a[i] = 2, ++tmp; else a[i] = 0; } playRound(a, b); for (int i = 0; i < N; ++i) if (a[i] == b[i]) return i; } int maxValue(int N, int W) { // TODO: Implement Subtask 2 solution here. // You may leave this function unmodified if you are not attempting this // subtask. int a[N], b[N]; vector<int> v(N); iota(v.begin(), v.end(), 0); while (v.size() > 1) { fill(a, a + N, 0); for (int i : v) a[i] = W / v.size(); playRound(a, b); v.clear(); for (int i = 0; i < N; ++i) if (b[i] > a[i] && a[i]) v.push_back(i); } return v[0]; } int greaterValue(int N, int W) { // TODO: Implement Subtask 3 solution here. // You may leave this function unmodified if you are not attempting this // subtask. int a[N], b[N]; fill(a + 2, a + N, 0); a[0] = a[1] = 4; playRound(a, b); if (b[0] > a[0] ^ b[1] > a[1]) return b[0] > a[0] ? 0 : 1; if (b[0] > a[0]) { fill(a, a + N, 1); playRound(a, b); if (b[0] > a[0] ^ b[1] > a[1]) return b[0] > a[0] ? 0 : 1; fill(a + 2, a + N, 0); a[0] = a[1] = b[0] > a[0] ? 10 : 7; playRound(a, b); return b[0] > a[0] ? 0 : 1; } else { a[0] = a[1] = 1; playRound(a, b); if (b[0] > a[0] ^ b[1] > a[1]) return b[0] > a[0] ? 0 : 1; a[0] = a[1] = 2; playRound(a, b); return b[0] > a[0] ? 0 : 1; } } 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 { // TODO: Implement Subtask 5 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } }

Compilation message (stderr)

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:48:14: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   48 |     if (b[0] > a[0] ^ b[1] > a[1])
      |         ~~~~~^~~~~~
koala.cpp:53:18: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   53 |         if (b[0] > a[0] ^ b[1] > a[1])
      |             ~~~~~^~~~~~
koala.cpp:63:18: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   63 |         if (b[0] > a[0] ^ b[1] > a[1])
      |             ~~~~~^~~~~~
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^
#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...