Submission #309590

#TimeUsernameProblemLanguageResultExecution timeMemory
309590aZvezdaGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#ifndef __GONDOLA_H__ #define __GONDOLA_H__ #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; typedef long double ld; typedef unsigned long long ull; template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } const ll mod = 1e9 + 9; template<class T> inline void fix(T &x) {if(labs(x) >= mod) {x %= mod;} if(x < 0) {x += mod;}} #define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl bool different(int n, int inputSeq[]) { vector<int> ret; for(int i = 0; i < n; i ++) { ret.push_back(inputSeq[i]); } sort(ret.begin(), ret.end()); for(int i = 0; i < n - 1; i ++) { if(ret[i] == ret[i + 1]) { return false; } } return true; } int valid(int n, int inputSeq[]) { int ind = -1; for(int i = 0; i < n; i ++) { if(inputSeq[i] <= n) { ind = i; break; } } if(ind != -1) { int rot = (-inputSeq[ind] + ind + 1 + n) % n; rotate(inputSeq, inputSeq + rot, inputSeq + n); } for(int i = 0; i < n; i ++) { if(inputSeq[i] <= n && inputSeq[i] != i + 1) { return 0; } } return different(n, inputSeq); } //---------------------- const int MAX_N = 3e5 + 10; int arr[MAX_N]; int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int ind = -1; vector<pair<int, int> > pos; for(int i = 0; i < n; i ++) { if(gondolaSeq[i] <= n) { ind = i; break; } } sort(pos.begin(), pos.end()); if(ind != -1) { int rot = (-gondolaSeq[ind] + ind + 1 + n) % n; rotate(gondolaSeq, gondolaSeq + rot, gondolaSeq + n); } for(int i = 0; i < n; i ++) { arr[i] = i + 1; if(gondolaSeq[i] > n) { pos.push_back({gondolaSeq[i], i}); } } sort(pos.begin(), pos.end()); int l = 0, curr = n + 1; for(auto it : pos) { while(curr <= it.first) { replacementSeq[l ++] = arr[it.second]; arr[it.second] = curr; curr ++; } } return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { int ind = -1; vector<pair<int, int> > pos; for(int i = 0; i < n; i ++) { if(gondolaSeq[i] <= n) { ind = i; break; } } sort(pos.begin(), pos.end()); if(ind != -1) { int rot = (-gondolaSeq[ind] + ind + 1 + n) % n; rotate(gondolaSeq, gondolaSeq + rot, gondolaSeq + n); } for(int i = 0; i < n; i ++) { arr[i] = i + 1; if(gondolaSeq[i] > n) { pos.push_back({gondolaSeq[i], i}); } } sort(pos.begin(), pos.end()); int l = 0, curr = n + 1, lft = pos.size(); ll ret = 1; for(auto it : pos) { while(curr <= it.first) { if(curr != it.first) { ret = (ret * (ll)lft) % mod; } curr ++; } lft --; } return ret; } #endif /* __GONDOLA_H__ */

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:95:12: error: 'gondolaSeq' was not declared in this scope
   95 |         if(gondolaSeq[i] <= n) {
      |            ^~~~~~~~~~
gondola.cpp:102:21: error: 'gondolaSeq' was not declared in this scope
  102 |         int rot = (-gondolaSeq[ind] + ind + 1 + n) % n;
      |                     ^~~~~~~~~~
gondola.cpp:107:12: error: 'gondolaSeq' was not declared in this scope
  107 |         if(gondolaSeq[i] > n) {
      |            ^~~~~~~~~~
gondola.cpp:108:45: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
  108 |             pos.push_back({gondolaSeq[i], i});
      |                                             ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from gondola.cpp:4:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
gondola.cpp:112:9: warning: unused variable 'l' [-Wunused-variable]
  112 |     int l = 0, curr = n + 1, lft = pos.size();
      |         ^