Submission #864089

#TimeUsernameProblemLanguageResultExecution timeMemory
864089nguyentunglamCoins (IOI17_coins)C++17
0 / 100
2 ms1116 KiB
#include "coins.h" #include<bits/stdc++.h> using namespace std; std::vector<int> coin_flips(std::vector<int> b, int c) { int sum = 0; for(int i = 0; i < b.size(); i++) if (b[i]) sum += i; for (int i = 0; i < b.size(); i++) { if (b[i]) sum -= i; else sum += i; if (sum % b.size() == c) return {i}; if (b[i]) sum += i; else sum -= i; } assert(false); } int find_coin(std::vector<int> b) { int ret = 0; for(int i = 0; i < b.size(); i++) if (b[i]) ret += i; return ret % b.size(); }

Compilation message (stderr)

coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:8:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |    for(int i = 0; i < b.size(); i++) if (b[i]) sum += i;
      |                   ~~^~~~~~~~~~
coins.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |    for (int i = 0; i < b.size(); i++) {
      |                    ~~^~~~~~~~~~
coins.cpp:14:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |        if (sum % b.size() == c) return {i};
      |            ~~~~~~~~~~~~~~~^~~~
coins.cpp: In function 'int find_coin(std::vector<int>)':
coins.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    for(int i = 0; i < b.size(); i++) if (b[i]) ret += 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...