제출 #316958

#제출 시각아이디문제언어결과실행 시간메모리
316958VROOM_VARUNGondola (IOI14_gondola)C++14
컴파일 에러
0 ms0 KiB
/* ID: varunra2 LANG: C++ TASK: gondola */ #include<bits/stdc++.h> #include "gondola.h" using namespace std; #ifdef DEBUG #include "lib/debug.h" #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define debug_arr(...) \ cerr << "[" << #__VA_ARGS__ << "]:", debug_arr(__VA_ARGS__) #pragma GCC diagnostic ignored "-Wsign-compare" //#pragma GCC diagnostic ignored "-Wunused-parameter" //#pragma GCC diagnostic ignored "-Wunused-variable" #else #define debug(...) 42 #endif #define EPS 1e-9 #define IN(A, B, C) assert(B <= A && A <= C) #define INF (int)1e9 #define MEM(a, b) memset(a, (b), sizeof(a)) #define MOD 1000000009 #define MP make_pair #define PB push_back #define all(cont) cont.begin(), cont.end() #define rall(cont) cont.end(), cont.begin() #define x first #define y second const double PI = acos(-1.0); typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef map<int, int> MPII; typedef multiset<int> MSETI; typedef set<int> SETI; typedef set<string> SETS; typedef vector<int> VI; typedef vector<PII> VII; typedef vector<VI> VVI; typedef vector<string> VS; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define sz(x) (int)(x).size() typedef pair<int, int> pii; typedef vector<int> vi; #pragma GCC diagnostic ignored "-Wsign-compare" // util functions int n; bool good(int val) { return val >= 1 and val <= n; } VI get(int *vals) { VI ret; for(int i = 0; i < n; i++) { if(good(vals[i])) ret.PB(i); } return ret; } VI brokeget(int *vals) { VI ret; } bool distinct(int *inputSeq) { MPII mp; for(int i = 0; i < n; i++) { mp[inputSeq[i]]++; if(mp[inputSeq[i]] >= 2) return false; } return true; } bool valid(int N, int *inputSeq) { n = N; VI inds = get(inputSeq); if(!distinct(inputSeq)) return false; if(sz(inds) == 0) return true; for(int i = inds[0], val = inputSeq[inds[0]], cnt = 0; cnt < n; cnt++, val = val%n + 1, i = (i + 1)%n) { if(!good(inputSeq[i])) continue; if(inputSeq[i] != val) return false; } return true; } VII genVals(int n, int *gondolaSeq) { VII vals; for(int i = 0; i < n; i++) { if(!good(gondolaSeq[i])) { vals.PB(MP(gondolaSeq[i], i)); } } return vals; } int replacement(int N, int *gondolaSeq, int *replacementSeq) { assert(valid(n, gondolaSeq)); n = N; VII vals = genVals(n, gondolaSeq); if(vals.empty()) return 0; sort(all(vals)); int lst = n + 1; int cnt = 0; for(int i = 0; i < sz(vals); i++) { while(gondolaSeq[vals[i].y] != vals[i].x) { replacementSeq[cnt] = gondolaSeq[vals[i].y]; gondolaSeq[vals[i].y] = lst; lst++; cnt++; } } return cnt; } ll binpow(ll a, ll b) { if(b == 0) return 1ll; if(b == 1) return a; ll mid = binpow(a, b/2); ll mult = (mid * mid) % MOD; if(b%2) return (mult * a) % MOD; return mult; } int countReplacement(int N, int *inputSeq) { n = N; if(!valid(n, inputSeq)) return 0; ll ret = 1; VII vals = genVals(n, inputSeq); if(vals.empty()) return 1; sort(all(vals)); int lst = n; int cnt = sz(vals); if(cnt == n) ret *= n; for(int i = 0; i < sz(vals); i++) { int len = vals[i].x - lst - 1; ret *= binpow(cnt, len); ret %= MOD; } return ret; } // int main() { // #ifndef ONLINE_JUDGE // freopen("gondola.in", "r", stdin); // freopen("gondola.out", "w", stdout); // #endif // cin.sync_with_stdio(0); cin.tie(0); // return 0; // }

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

gondola.cpp: In function 'VI brokeget(int*)':
gondola.cpp:72:1: warning: no return statement in function returning non-void [-Wreturn-type]
   72 | }
      | ^
gondola.cpp: At global scope:
gondola.cpp:83:6: error: ambiguating new declaration of 'bool valid(int, int*)'
   83 | bool valid(int N, int *inputSeq) {
      |      ^~~~~
In file included from gondola.cpp:8:
gondola.h:8:5: note: old declaration 'int valid(int, int*)'
    8 | int valid(int n, int inputSeq[]);
      |     ^~~~~