Submission #1238001

#TimeUsernameProblemLanguageResultExecution timeMemory
1238001ayathkCoins (IOI17_coins)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "coins.h" using namespace std; #define fi first #define se second #define all(a) a.begin(),a.end() #define pb push_back const int maxn = 2e5+1; vector <int> coin_flips(vector <int> b, int c){ vector <int> d; int o = 0 ,z = 0; for(int i : b){ if(i == 1)o++; else z++; } int ch = -1; if(o > z)ch = 1; else ch = 0; if(b[c] == ch){ for(int i = 0;i < n;i++){ if(b[i] == ch && i != c)d.push_back(i); } } else{ d.push_back(c); } return d; } int find_coin(vector <int> b){ int o = 0 ,z = 0; for(int i : b){ if(i == 1)o++; else z++; } int ch = -1; if(o < z)ch = 1; else ch = 0; for(int i = 0;i < b.size();i++){ if(b[i] == ch)return i; } }

Compilation message (stderr)

coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:24:23: error: 'n' was not declared in this scope
   24 |     for(int i = 0;i < n;i++){
      |                       ^
coins.cpp: In function 'int find_coin(std::vector<int>)':
coins.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^