Submission #918539

# Submission time Handle Problem Language Result Execution time Memory
918539 2024-01-30T06:19:42 Z fuad27 Coins (IOI17_coins) C++17
Compilation error
0 ms 0 KB
#include "coins.h"

std::vector<int> coin_flips(std::vector<int> b, int c) {
  int x = c;
  for(int i = 0;i<b.size();i++)
    x^=(b[i]?i:0);
  vector<int> ans=vector<int>(63);
  ans[x]=1;
  return ans;

}

int find_coin(std::vector<int> b) {
    int x =0;
    for(int i = 0;i<b.size();i++)
      x^=(b[i]?i:0);
    return x;
}

Compilation message

coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:5:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |   for(int i = 0;i<b.size();i++)
      |                 ~^~~~~~~~~
coins.cpp:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> ans=vector<int>(63);
      |   ^~~~~~
coins.cpp:7:3: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from coins.h:1,
                 from coins.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from coins.h:1,
                 from coins.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
coins.cpp:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> ans=vector<int>(63);
      |          ^~~
coins.cpp:8:3: error: 'ans' was not declared in this scope
    8 |   ans[x]=1;
      |   ^~~
coins.cpp: In function 'int find_coin(std::vector<int>)':
coins.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 0;i<b.size();i++)
      |                   ~^~~~~~~~~