제출 #734930

#제출 시각아이디문제언어결과실행 시간메모리
734930sandry24곤돌라 (IOI14_gondola)C++17
컴파일 에러
0 ms0 KiB
#include "gondola.h" map<int, int> freq; int valid(int n, int inputSeq[]){ int index_under_n = -1; for(int i = 0; i < n; i++){ freq[inputSeq[i]]++; if(freq[inputSeq[i]] > 1) return 0; if(inputSeq[i] <= n) index_under_n = i; } if(index_under_n == -1) return 1; int index = (index_under_n == n-1 ? 0 : index_under_n + 1); int next = (inputSeq[index_under_n] == n ? 1 : inputSeq[index_under_n] + 1); while(index != index_under_n){ if(inputSeq[index] < n){ if(inputSeq[index] != next){ return 0; } } index = (index == n-1 ? 0 : index + 1); next = (next == n ? 1 : next + 1); } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ int index = -1, cnt = 0, next; for(int i = 0; i < n; i++) if(gondolaSeq[i] <= n) index = i; if(index == -1){ index = 0; next = 1; } else next = gondolaSeq[index]; vector<pi> temp; int current = n+1; while(cnt != n){ if(gondolaSeq[index] != next) temp.pb({gondolaSeq[index], next}); index = (index == n-1 ? 0 : index + 1); next = (next == n ? 1 : next + 1); cnt++; } sort(temp.begin(), temp.end()); int ind = 0; for(int i = 0; i < temp.size(); i++){ while(temp[i].f != temp[i].s){ replacementSeq[ind] = temp[i].s; temp[i].s = current; current++; ind++; } } return ind; } ll bin_pow(ll a, ll b, ll mod){ ll ans = 1; while(b > 0){ if(b & 1) ans = ans * a % mod; a = a * a % mod; b /= 2; } return ans; } int countReplacement(int n, int inputSeq[]){ if(!valid(n, inputSeq)) return 0; int index = -1, cnt = 0, next; for(int i = 0; i < n; i++) if(inputSeq[i] <= n) index = i; if(index == -1){ index = 0; next = 1; } else next = inputSeq[index]; vi temp; int current = n+1; while(cnt != n){ if(inputSeq[index] != next) temp.pb(inputSeq[index]); index = (index == n-1 ? 0 : index + 1); next = (next == n ? 1 : next + 1); cnt++; } ll ans = 1, mod = 1e9+7; sort(temp.begin(), temp.end()); for(int i = 0; i < temp.size(); i++){ ll diff = temp[i] - current; ans *= bin_pow(temp.size() - i, diff, mod); ans %= mod; current = temp[i] + 1; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp:3:1: error: 'map' does not name a type
    3 | map<int, int> freq;
      | ^~~
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:8:9: error: 'freq' was not declared in this scope
    8 |         freq[inputSeq[i]]++;
      |         ^~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:39:5: error: 'vector' was not declared in this scope
   39 |     vector<pi> temp;
      |     ^~~~~~
gondola.cpp:39:12: error: 'pi' was not declared in this scope
   39 |     vector<pi> temp;
      |            ^~
gondola.cpp:39:16: error: 'temp' was not declared in this scope
   39 |     vector<pi> temp;
      |                ^~~~
gondola.cpp:48:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   48 |     sort(temp.begin(), temp.end());
      |     ^~~~
      |     short
gondola.cpp: At global scope:
gondola.cpp:61:1: error: 'll' does not name a type
   61 | ll bin_pow(ll a, ll b, ll mod){
      | ^~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:83:5: error: 'vi' was not declared in this scope
   83 |     vi temp;
      |     ^~
gondola.cpp:87:13: error: 'temp' was not declared in this scope
   87 |             temp.pb(inputSeq[index]);
      |             ^~~~
gondola.cpp:92:5: error: 'll' was not declared in this scope
   92 |     ll ans = 1, mod = 1e9+7;
      |     ^~
gondola.cpp:93:10: error: 'temp' was not declared in this scope
   93 |     sort(temp.begin(), temp.end());
      |          ^~~~
gondola.cpp:93:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   93 |     sort(temp.begin(), temp.end());
      |     ^~~~
      |     short
gondola.cpp:95:11: error: expected ';' before 'diff'
   95 |         ll diff = temp[i] - current;
      |           ^~~~~
      |           ;
gondola.cpp:96:9: error: 'ans' was not declared in this scope
   96 |         ans *= bin_pow(temp.size() - i, diff, mod);
      |         ^~~
gondola.cpp:96:41: error: 'diff' was not declared in this scope
   96 |         ans *= bin_pow(temp.size() - i, diff, mod);
      |                                         ^~~~
gondola.cpp:96:47: error: 'mod' was not declared in this scope
   96 |         ans *= bin_pow(temp.size() - i, diff, mod);
      |                                               ^~~
gondola.cpp:96:16: error: 'bin_pow' was not declared in this scope
   96 |         ans *= bin_pow(temp.size() - i, diff, mod);
      |                ^~~~~~~
gondola.cpp:100:12: error: 'ans' was not declared in this scope
  100 |     return ans;
      |            ^~~