제출 #355614

#제출 시각아이디문제언어결과실행 시간메모리
355614Mefarnis곤돌라 (IOI14_gondola)C++14
20 / 100
48 ms5100 KiB
#include <bits/stdc++.h> #include "gondola.h" #define maxn 100003 #define maxv 250001 using namespace std; int idx[maxv]; int init[maxn]; void calcInit(int n, int inputSeq[], int minIdx) { if(minIdx == -1) for( int i = 0 ; i < n ; i++ ) init[i] = i+1; else for( int i = 0 ; i < n ; i++ ) { int d = (i-minIdx+n) % n; init[i] = inputSeq[minIdx]+d; } } int valid(int n, int inputSeq[]) { int minIdx = -1; set<int> s; for( int i = 0 ; i < n ; i++ ) { if(s.find(inputSeq[i]) != s.end()) return 0; s.insert(inputSeq[i]); if(inputSeq[i] <= n) { if(minIdx == -1 || inputSeq[i] < inputSeq[minIdx]) minIdx = i; } } calcInit(n,inputSeq,minIdx); if(minIdx == -1) return 1; for( int i = 0 ; i < n ; i++ ) if(inputSeq[i] <= n) { if(init[i] != inputSeq[i]) return 0; } return 1; } int replacement(int n, int inputSeq[], int replacementSeq[]) { if(!valid(n,inputSeq)) return 0; int maxIdx = -1; memset(idx,-1,sizeof(idx)); for( int i = 0 ; i < n ; i++ ) { idx[inputSeq[i]] = i; if(maxIdx == -1 || inputSeq[i] > inputSeq[maxIdx]) maxIdx = i; } int cnt = 0; int curr = init[maxIdx]; int maxVal = inputSeq[maxIdx]; for( int i = n+1 ; i <= maxVal ; i++ ) { if(idx[i] == -1 || i == maxVal) { replacementSeq[cnt++] = curr; curr = i; } else replacementSeq[cnt++] = init[idx[i]]; } return cnt; } int countReplacement(int n, int inputSeq[]) { if(!valid(n,inputSeq)) return 0; }

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

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
   71 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...