Submission #524215

#TimeUsernameProblemLanguageResultExecution timeMemory
524215LoboUnscrambling a Messy Bug (IOI16_messy)C++17
Compilation error
0 ms0 KiB
#include "messy.h" #include<bits/stdc++.h> using namespace std; const long long inf = (long long) 1e18 + 10; const int inf1 = (int) 1e9 + 10; // #define int long long #define dbl long double #define endl '\n' #define sc second #define fr first #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() #define maxn vector<int> restore_permutation(int n, int w, int r) { vector<int> v; for(int i = 0; i < n; i++) { v.pb(mp(rand()%150,i)); } sort(all(v)); vector<int> p1(n,0); for(int i = 1; i <= n; i++) { string s; for(int j = 0; j < i; j++) s.pb('1'); for(int j = 0; j < n-i; j++) s.pb('0'); add_element(s); } compile_set(); string cur(n,'0'); for(int i = 0; i < n; i++) { //encontrar qual j tem p[j] = i for(auto X : v) { int j = X.sc; if(cur[j] == '1') continue; cur[j] = '1'; bool ok; // cout << cur << " " << ok ? "false" : "true" << endl; ok = check_element(cur); // cout << cur << " " << ok ? "false" : "true" << endl; if(ok) { p1[j] = i; break; } cur[j] = '0'; } } return p1; }

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:22:30: error: no matching function for call to 'std::vector<int>::push_back(std::pair<int, int>)'
   22 |         v.pb(mp(rand()%150,i));
      |                              ^
In file included from /usr/include/c++/10/vector:67,
                 from messy.h:3,
                 from messy.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
messy.cpp:10:12: error: request for member 'second' in 'X', which is of non-class type 'int'
   10 | #define sc second
      |            ^~~~~~
messy.cpp:42:23: note: in expansion of macro 'sc'
   42 |             int j = X.sc;
      |                       ^~