답안 #122801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122801 2019-06-29T09:52:00 Z brcode 곤돌라 (IOI14_gondola) C++14
25 / 100
57 ms 4728 KB
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include "gondola.h"
 
using namespace std;
int arr[2500];
int valid(int n, int inputSeq[]){
    map<int,int> m1;
    int holdmin = 1e9;
    int ind = 0;
    for(int i=0;i<n;i++){
        if(m1[inputSeq[i]] == 1){
            return 0;
            
        }
        if(inputSeq[i]<holdmin){
            holdmin = inputSeq[i];
            ind = i;
        }
        m1[inputSeq[i]] = 1;
    }
   
    for(int i=ind;i<n;i++){
        if(inputSeq[i]<=n && inputSeq[i]!=holdmin){
            return 0;
        }
        holdmin++;
    }
    if(ind == 0){
        return 1;
    }
    
    for(int i=0;i<ind;i++){
        if(inputSeq[i]<=n && inputSeq[i]!=holdmin){
           // cout<<inputSeq[i]<<endl;
            return 0;
        }
        holdmin++;
    }
    return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
   int holdmin =1e9;
   int pos = 0;
   for(int i=0;i<n;i++){
       if(gondolaSeq[i]<holdmin){
           holdmin = gondolaSeq[i];
           pos = i;
       }
   }
   
   vector<pair<int,int>> v1;
   if(holdmin == 1e9){
       for(int i=0;i<n;i++){
           v1.push_back(make_pair(gondolaSeq[i],i+1));
       }
   }else{
       int x = holdmin;
       for(int i=pos;i<n;i++){
           if(gondolaSeq[i]>n){
               v1.push_back(make_pair(gondolaSeq[i],x));
               //cout<<gondolaSeq[i]<<" "<<x<<endl;
           }
           x++;
           if(x == n+1){
               x = 1;
           }
       }
       for(int i=0;i<pos;i++){
           if(gondolaSeq[i]>n){
               v1.push_back(make_pair(gondolaSeq[i],x));
               //cout<<gondolaSeq[i]<<" "<<x<<endl;
           }
           x++;
           if(x == n+1){
               x = 1;
           }
       }
   }
   sort(v1.begin(),v1.end());
   int start = n+1;
   int ind = 0;
   for(auto x:v1){
       int curr = x.first;
       int val = x.second;
       for(int i=start;i<=curr;i++){
           replacementSeq[ind] = val;
           val = i;
           ind++;
       }
       start = curr+1;
   }
   return ind;
}
int countReplacement(int n, int inputSeq[]){
  return 0;
}
 
/*int main(){
    int arr[8] = {5, 1, 2, 3, 4};
    int arr2[45];
    cout<<replacement(5,arr,arr2)<<endl;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 20 ms 2140 KB Output is correct
7 Correct 13 ms 704 KB Output is correct
8 Correct 35 ms 3984 KB Output is correct
9 Correct 12 ms 1528 KB Output is correct
10 Correct 48 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 19 ms 2168 KB Output is correct
7 Correct 13 ms 760 KB Output is correct
8 Correct 35 ms 3960 KB Output is correct
9 Correct 11 ms 1528 KB Output is correct
10 Correct 47 ms 4472 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 25 ms 2168 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 57 ms 4728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 300 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 3 ms 376 KB Integer 4331 violates the range [1, 72]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 504 KB Integer 4331 violates the range [1, 72]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -