제출 #589048

#제출 시각아이디문제언어결과실행 시간메모리
589048fuad27곤돌라 (IOI14_gondola)C++17
컴파일 에러
0 ms0 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; #define prev(i) ((i-1+n)%n) int valid(int n, int a[]) { // int cnt = a[0]-1; // for(int i = 1;i<n-cnt;i++) { // // if(a[i] != a[i-1]+1) { // return 0; // } // } // for(int i = n-cnt+1;i<n;i++) { // if(a[i]!=a[i-1]+1)return 0; // } // if(cnt==0)return 1; // if(a[0] != a[n-1]+1)return 0; // return 1; } int replacement(int n, int gondolaseq[], int replacementseq[]) { int cnt=0; for(int i = 0;i<n;i++) { if(gondolaSeq[i]>n)cnt++; } if(cnt == 0)return 0; else if(cnt == n) { for(int i = 0;i<n;i++) { replacementSeq[i] = gondolaSeq[i]-n; } return n; } else { vector<pair<int,int>> res; res.push_back(make_pair(n,n)); for(int i = 0;i<n;i++) { for(int i = 0;i<n;i++) { if(gondolaSeq[i] > n and gondolaSeq[prev(i)]<=n) { int tmp = gondolaSeq[i]; gondolaSeq[i] = (gondolaSeq[prev(i)]%n)+1; res.push_back(make_pair(tmp, gondolaSeq[i])); } } } sort(res.begin(), res.end()); vector<int> ans; for(int i=1;i<(int)res.size();i++) { ans.push_back(res[i].second); for(int j = max(res[i].second, res[i-1].first);j<res[i].first-1;j++) { ans.push_back(j+1); } } for(int i=0;i<(int)ans.size();i++) { replacementSeq[i]=ans[i]; } return (int)ans.size(); } return 0; } int countReplacement(int n, int inputSeq[]) { return -3; }

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

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | }
      | ^
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:26:6: error: 'gondolaSeq' was not declared in this scope; did you mean 'gondolaseq'?
   26 |   if(gondolaSeq[i]>n)cnt++;
      |      ^~~~~~~~~~
      |      gondolaseq
gondola.cpp:31:4: error: 'replacementSeq' was not declared in this scope; did you mean 'replacementseq'?
   31 |    replacementSeq[i] = gondolaSeq[i]-n;
      |    ^~~~~~~~~~~~~~
      |    replacementseq
gondola.cpp:31:24: error: 'gondolaSeq' was not declared in this scope; did you mean 'gondolaseq'?
   31 |    replacementSeq[i] = gondolaSeq[i]-n;
      |                        ^~~~~~~~~~
      |                        gondolaseq
gondola.cpp:40:8: error: 'gondolaSeq' was not declared in this scope; did you mean 'gondolaseq'?
   40 |     if(gondolaSeq[i] > n and gondolaSeq[prev(i)]<=n) {
      |        ^~~~~~~~~~
      |        gondolaseq
gondola.cpp:56:4: error: 'replacementSeq' was not declared in this scope; did you mean 'replacementseq'?
   56 |    replacementSeq[i]=ans[i];
      |    ^~~~~~~~~~~~~~
      |    replacementseq