Submission #422307

#TimeUsernameProblemLanguageResultExecution timeMemory
422307APROHACK곤돌라 (IOI14_gondola)C++17
Compilation error
0 ms0 KiB
#include "gondola.h"
#include <bits/stdc++.h>
#define PB push_back
#define S second
#define F first
using namespace std; 
int valid(int n, int inputSeq[]){
  bool ocurr[250001];
  for(int i = 0 ; i < 250001 ; i++){
    ocurr[i]=false; 
  }  //bool pst=false;
  int cur=-1;  for(int i = 0 ; i < n ; i++){
    if(ocurr[inputSeq[i]]){   
      return 0;   
    }   
    ocurr[inputSeq[i]]=true;  
    if(inputSeq[i]<=n){    
      if(cur==-1){      
        cur=inputSeq[i]; 
      }else{      
        if(inputSeq[i]!=cur)return 0;
      }
    }    
    if(cur!=-1)cur++;  
    if(cur==n+1)cur=1; 
  }  
  return 1;
} //----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
  int pos=-1; 
  vector<pair<int, int> >wow;
  int mascara[n]; 
  for(int i = 0 ; i < n ; i++){  
    if(gondolaSeq[i]>n){    
      wow.PB({gondolaSeq[i], i}); 
    }else{   
      pos=i;   
    } 
  } 
  int cur=gondolaSeq[pos]; 
  for(int i = pos ; i >=0 ; i--){ 
    mascara[i]=cur; 
    cur--;  
    if(cur==0)cur=n; 
  } 
  cur=gondolaSeq[pos];  
  for(int i = pos ; i <n ; i++){  
    mascara[i]=cur;   
    cur++;   
    if(cur==n+1)cur=1;
  }  
  int l, p=n+1, indx=0;
  sort(wow.begin(), wow.end());
  //numero, indice 
  for(int i = 0 ; i < wow.size(); i++){  
    while(mascara[wow[i].S]<wow[i].F){    
      replacementSeq[indx]=mascara[wow[i].S];   
      mascara[wow[i].S]=p;    
      //cout<<replacementSeq[indx]<<endl;  
      p++;  
      indx++;  
    } 
  }  return indx;
} //----------------------
int countReplacement(int n, int inputSeq[]){ 
  if(valid(n, inputSeq)==0)return 0;
  vector<int >whew; 
  int mxcur=n;
  bool fixed=false;  
  for(int i = 0 ; i < n ; i++){  
    if(inputSeq[i]>n){    
      whew.PB(inputSeq[i]);   
    }else{   
      fixed=true; 
    }  
  }  
  long long rta = 1, MOD = 1000000007; 
  sort(whew.begin(), whew.end());
  for(int i = 0 ; i < whew.size() ; i++){  
    int nxt=(whew[i]), nums; 
    nums=(nxt-1)-(mxcur);  
    if(nums!=0&&(whew.size()-i)>1)rta*=((nums%MOD)*(whew.size()-i))%MOD;  
    rta%=MOD;   
    mxcur=nxt;   
    //wow.pop(); 
  } 
  if(!fixed){   
    rta*=n;   
    rta%=MOD; 
  } 
  return rta;
}

Compilation message (stderr)

gondola.cpp:8:2: error: extended character   is not valid in an identifier
    8 |   bool ocurr[250001];
      |  ^
gondola.cpp:9:2: error: extended character   is not valid in an identifier
    9 |   for(int i = 0 ; i < 250001 ; i++){
      |  ^
gondola.cpp:10:2: error: extended character   is not valid in an identifier
   10 |     ocurr[i]=false;
      |  ^
gondola.cpp:10:5: error: extended character   is not valid in an identifier
   10 |     ocurr[i]=false;
      |    ^
gondola.cpp:11:5: error: extended character   is not valid in an identifier
   11 |   }  //bool pst=false;
      |     ^
gondola.cpp:12:2: error: extended character   is not valid in an identifier
   12 |   int cur=-1;  for(int i = 0 ; i < n ; i++){
      |  ^
gondola.cpp:12:16: error: extended character   is not valid in an identifier
   12 |   int cur=-1;  for(int i = 0 ; i < n ; i++){
      |               ^
gondola.cpp:13:2: error: extended character   is not valid in an identifier
   13 |     if(ocurr[inputSeq[i]]){  
      |  ^
gondola.cpp:13:5: error: extended character   is not valid in an identifier
   13 |     if(ocurr[inputSeq[i]]){  
      |    ^
gondola.cpp:13:31: error: extended character   is not valid in an identifier
   13 |     if(ocurr[inputSeq[i]]){  
      |                             ^
gondola.cpp:14:2: error: extended character   is not valid in an identifier
   14 |       return 0;  
      |  ^
gondola.cpp:14:5: error: extended character   is not valid in an identifier
   14 |       return 0;  
      |    ^
gondola.cpp:14:8: error: extended character   is not valid in an identifier
   14 |       return 0;  
      |      ^
gondola.cpp:14:20: error: extended character   is not valid in an identifier
   14 |       return 0;  
      |                 ^
gondola.cpp:15:7: error: extended character   is not valid in an identifier
   15 |     }  
      |       ^
gondola.cpp:16:2: error: extended character   is not valid in an identifier
   16 |     ocurr[inputSeq[i]]=true;  
      |  ^
gondola.cpp:16:5: error: extended character   is not valid in an identifier
   16 |     ocurr[inputSeq[i]]=true;  
      |    ^
gondola.cpp:16:32: error: extended character   is not valid in an identifier
   16 |     ocurr[inputSeq[i]]=true;  
      |                              ^
gondola.cpp:17:2: error: extended character   is not valid in an identifier
   17 |     if(inputSeq[i]<=n){    
      |  ^
gondola.cpp:17:5: error: extended character   is not valid in an identifier
   17 |     if(inputSeq[i]<=n){    
      |    ^
gondola.cpp:17:27: error: extended character   is not valid in an identifier
   17 |     if(inputSeq[i]<=n){    
      |                         ^
gondola.cpp:17:30: error: extended character   is not valid in an identifier
   17 |     if(inputSeq[i]<=n){    
      |                           ^
gondola.cpp:18:2: error: extended character   is not valid in an identifier
   18 |       if(cur==-1){      
      |  ^
gondola.cpp:18:5: error: extended character   is not valid in an identifier
   18 |       if(cur==-1){      
      |    ^
gondola.cpp:18:8: error: extended character   is not valid in an identifier
   18 |       if(cur==-1){      
      |      ^
gondola.cpp:18:23: error: extended character   is not valid in an identifier
   18 |       if(cur==-1){      
      |                    ^
gondola.cpp:18:26: error: extended character   is not valid in an identifier
   18 |       if(cur==-1){      
      |                      ^
gondola.cpp:18:29: error: extended character   is not valid in an identifier
   18 |       if(cur==-1){      
      |                        ^
gondola.cpp:19:2: error: extended character   is not valid in an identifier
   19 |         cur=inputSeq[i];
      |  ^
gondola.cpp:19:5: error: extended character   is not valid in an identifier
   19 |         cur=inputSeq[i];
      |    ^
gondola.cpp:19:8: error: extended character   is not valid in an identifier
   19 |         cur=inputSeq[i];
      |      ^
gondola.cpp:19:11: error: extended character   is not valid in an identifier
   19 |         cur=inputSeq[i];
      |        ^
gondola.cpp:20:14: error: extended character   is not valid in an identifier
   20 |       }else{      
      |              ^
gondola.cpp:20:17: error: extended character   is not valid in an identifier
   20 |       }else{      
      |                ^
gondola.cpp:20:20: error: extended character   is not valid in an identifier
   20 |       }else{      
      |                  ^
gondola.cpp:21:2: error: extended character   is not valid in an identifier
   21 |         if(inputSeq[i]!=cur)return 0;
      |  ^
gondola.cpp:21:5: error: extended character   is not valid in an identifier
   21 |         if(inputSeq[i]!=cur)return 0;
      |    ^
gondola.cpp:21:8: error: extended character   is not valid in an identifier
   21 |         if(inputSeq[i]!=cur)return 0;
      |      ^
gondola.cpp:21:11: error: extended character   is not valid in an identifier
   21 |         if(inputSeq[i]!=cur)return 0;
      |        ^
gondola.cpp:23:2: error: extended character   is not valid in an identifier
   23 |     }    
      |  ^
gondola.cpp:23:8: error: extended character   is not valid in an identifier
   23 |     }    
      |       ^
gondola.cpp:23:11: error: extended character   is not valid in an identifier
   23 |     }    
      |         ^
gondola.cpp:24:2: error: extended character   is not valid in an identifier
   24 |     if(cur!=-1)cur++;  
      |  ^
gondola.cpp:24:5: error: extended character   is not valid in an identifier
   24 |     if(cur!=-1)cur++;  
      |    ^
gondola.cpp:24:25: error: extended character   is not valid in an identifier
   24 |     if(cur!=-1)cur++;  
      |                       ^
gondola.cpp:25:2: error: extended character   is not valid in an identifier
   25 |     if(cur==n+1)cur=1;
      |  ^
gondola.cpp:25:5: error: extended character   is not valid in an identifier
   25 |     if(cur==n+1)cur=1;
      |    ^
gondola.cpp:26:5: error: extended character   is not valid in an identifier
   26 |   }  
      |     ^
gondola.cpp:27:2: error: extended character   is not valid in an identifier
   27 |   return 1;
      |  ^
gondola.cpp:30:2: error: extended character   is not valid in an identifier
   30 |   int pos=-1;
      |  ^
gondola.cpp:31:2: error: extended character   is not valid in an identifier
   31 |   vector<pair<int, int> >wow;
      |  ^
gondola.cpp:32:2: error: extended character   is not valid in an identifier
   32 |   int mascara[n];
      |  ^
gondola.cpp:33:2: error: extended character   is not valid in an identifier
   33 |   for(int i = 0 ; i < n ; i++){  
      |  ^
gondola.cpp:33:34: error: extended character   is not valid in an identifier
   33 |   for(int i = 0 ; i < n ; i++){  
      |                                 ^
gondola.cpp:34:2: error: extended character   is not valid in an identifier
   34 |     if(gondolaSeq[i]>n){    
      |  ^
gondola.cpp:34:5: error: extended character   is not valid in an identifier
   34 |     if(gondolaSeq[i]>n){    
      |    ^
gondola.cpp:34:28: error: extended character   is not valid in an identifier
   34 |     if(gondolaSeq[i]>n){    
      |                          ^
gondola.cpp:34:31: error: extended character   is not valid in an identifier
   34 |     if(gondolaSeq[i]>n){    
      |                            ^
gondola.cpp:36:12: error: extended character   is not valid in an identifier
   36 |     }else{  
      |            ^
gondola.cpp:37:2: error: extended character   is not valid in an identifier
   37 |       pos=i;  
      |  ^
gondola.cpp:37:5: error: extended character   is not valid in an identifier
   37 |       pos=i;  
      |    ^
gondola.cpp:37:8: error: extended character   is not valid in an identifier
   37 |       pos=i;  
      |      ^
gondola.cpp:37:17: error: extended character   is not valid in an identifier
   37 |       pos=i;  
      |              ^
gondola.cpp:40:2: error: extended character   is not valid in an identifier
   40 |   int cur=gondolaSeq[pos];
      |  ^
gondola.cpp:41:2: error: extended character   is not valid in an identifier
   41 |   for(int i = pos ; i >=0 ; i--){
      |  ^
gondola.cpp:42:2: error: extended character   is not valid in an identifier
   42 |     mascara[i]=cur;
      |  ^
gondola.cpp:42:5: error: extended character   is not valid in an identifier
   42 |     mascara[i]=cur;
      |    ^
gondola.cpp:43:2: error: extended character   is not valid in an identifier
   43 |     cur--;  
      |  ^
gondola.cpp:43:5: error: extended character   is not valid in an identifier
   43 |     cur--;  
      |    ^
gondola.cpp:43:14: error: extended character   is not valid in an identifier
   43 |     cur--;  
      |            ^
gondola.cpp:44:2: error: extended character   is not valid in an identifier
   44 |     if(cur==0)cur=n;
      |  ^
gondola.cpp:44:5: error: extended character   is not valid in an identifier
   44 |     if(cur==0)cur=n;
      |    ^
gondola.cpp:46:2: error: extended character   is not valid in an identifier
   46 |   cur=gondolaSeq[pos];  
      |  ^
gondola.cpp:46:25: error: extended character   is not valid in an identifier
   46 |   cur=gondolaSeq[pos];  
      |                        ^
gondola.cpp:47:2: error: extended character   is not valid in an identifier
   47 |   for(int i = pos ; i <n ; i++){  
      |  ^
gondola.cpp:47:35: error: extended character   is not valid in an identifier
   47 |   for(int i = pos ; i <n ; i++){  
      |                                  ^
gondola.cpp:48:2: error: extended character   is not valid in an identifier
   48 |     mascara[i]=cur;  
      |  ^
gondola.cpp:48:5: error: extended character   is not valid in an identifier
   48 |     mascara[i]=cur;  
      |    ^
gondola.cpp:48:23: error: extended character   is not valid in an identifier
   48 |     mascara[i]=cur;  
      |                     ^
gondola.cpp:49:2: error: extended character   is not valid in an identifier
   49 |     cur++;  
      |  ^
gondola.cpp:49:5: error: extended character   is not valid in an identifier
   49 |     cur++;  
      |    ^
gondola.cpp:49:14: error: extended character   is not valid in an identifier
   49 |     cur++;  
      |            ^
gondola.cpp:50:2: error: extended character   is not valid in an identifier
   50 |     if(cur==n+1)cur=1;
      |  ^
gondola.cpp:50:5: error: extended character   is not valid in an identifier
   50 |     if(cur==n+1)cur=1;
      |    ^
gondola.cpp:51:5: error: extended character   is not valid in an identifier
   51 |   }  
      |     ^
gondola.cpp:52:2: error: extended character   is not valid in an identifier
   52 |   int l, p=n+1, indx=0;
      |  ^
gondola.cpp:53:2: error: extended character   is not valid in an identifier
   53 |   sort(wow.begin(), wow.end());
      |  ^
gondola.cpp:55:2: error: extended character   is not valid in an identifier
   55 |   for(int i = 0 ; i < wow.size(); i++){  
      |  ^
gondola.cpp:55:42: error: extended character   is not valid in an identifier
   55 |   for(int i = 0 ; i < wow.size(); i++){  
      |                                         ^
gondola.cpp:56:2: error: extended character   is not valid in an identifier
   56 |     while(mascara[wow[i].S]<wow[i].F){    
      |  ^
gondola.cpp:56:5: error: extended character   is not valid in an identifier
   56 |     while(mascara[wow[i].S]<wow[i].F){    
      |    ^
gondola.cpp:56:42: error: extended character   is not valid in an identifier
   56 |     while(mascara[wow[i].S]<wow[i].F){    
      |                                        ^
gondola.cpp:56:45: error: extended character   is not valid in an identifier
   56 |     while(mascara[wow[i].S]<wow[i].F){    
      |                                          ^
gondola.cpp:57:2: error: extended character   is not valid in an identifier
   57 |       replacementSeq[indx]=mascara[wow[i].S];  
      |  ^
gondola.cpp:57:5: error: extended character   is not valid in an identifier
   57 |       replacementSeq[indx]=mascara[wow[i].S];  
      |    ^
gondola.cpp:57:8: error: extended character   is not valid in an identifier
   57 |       replacementSeq[indx]=mascara[wow[i].S];  
      |      ^
gondola.cpp:57:50: error: extended character   is not valid in an identifier
   57 |       replacementSeq[indx]=mascara[wow[i].S];  
      |                                               ^
gondola.cpp:58:2: error: extended character   is not valid in an identifier
   58 |       mascara[wow[i].S]=p;    
      |  ^
gondola.cpp:58:5: error: extended character   is not valid in an identifier
   58 |       mascara[wow[i].S]=p;    
      |    ^
gondola.cpp:58:8: error: extended character   is not valid in an identifier
   58 |       mascara[wow[i].S]=p;    
      |      ^
gondola.cpp:58:31: error: extended character   is not valid in an identifier
   58 |       mascara[wow[i].S]=p;    
      |                            ^
gondola.cpp:58:34: error: extended character   is not valid in an identifier
   58 |       mascara[wow[i].S]=p;    
      |                              ^
gondola.cpp:60:2: error: extended character   is not valid in an identifier
   60 |       p++;  
      |  ^
gondola.cpp:60:5: error: extended character   is not valid in an identifier
   60 |       p++;  
      |    ^
gondola.cpp:60:8: error: extended character   is not valid in an identifier
   60 |       p++;  
      |      ^
gondola.cpp:60:15: error: extended character   is not valid in an identifier
   60 |       p++;  
      |            ^
gondola.cpp:61:2: error: extended character   is not valid in an identifier
   61 |       indx++;  
      |  ^
gondola.cpp:61:5: error: extended character   is not valid in an identifier
   61 |       indx++;  
      |    ^
gondola.cpp:61:8: error: extended character   is not valid in an identifier
   61 |       indx++;  
      |      ^
gondola.cpp:61:18: error: extended character   is not valid in an identifier
   61 |       indx++;  
      |               ^
gondola.cpp:63:5: error: extended character   is not valid in an identifier
   63 |   }  return indx;
      |     ^
gondola.cpp:66:2: error: extended character   is not valid in an identifier
   66 |   if(valid(n, inputSeq)==0)return 0;
      |  ^
gondola.cpp:67:2: error: extended character   is not valid in an identifier
   67 |   vector<int >whew;
      |  ^
gondola.cpp:68:2: error: extended character   is not valid in an identifier
   68 |   int mxcur=n;
      |  ^
gondola.cpp:69:2: error: extended character   is not valid in an identifier
   69 |   bool fixed=false;  
      |  ^
gondola.cpp:69:22: error: extended character   is not valid in an identifier
   69 |   bool fixed=false;  
      |                     ^
gondola.cpp:70:2: error: extended character   is not valid in an identifier
   70 |   for(int i = 0 ; i < n ; i++){  
      |  ^
gondola.cpp:70:34: error: extended character   is not valid in an identifier
   70 |   for(int i = 0 ; i < n ; i++){  
      |                                 ^
gondola.cpp:71:2: error: extended character   is not valid in an identifier
   71 |     if(inputSeq[i]>n){    
      |  ^
gondola.cpp:71:5: error: extended character   is not valid in an identifier
   71 |     if(inputSeq[i]>n){    
      |    ^
gondola.cpp:71:26: error: extended character   is not valid in an identifier
   71 |     if(inputSeq[i]>n){    
      |                        ^
gondola.cpp:71:29: error: extended character   is not valid in an identifier
   71 |     if(inputSeq[i]>n){    
      |                          ^
gondola.cpp:72:29: error: extended character   is not valid in an identifier
   72 |       whew.PB(inputSeq[i]);  
      |                             ^
gondola.cpp:73:12: error: extended character   is not valid in an identifier
   73 |     }else{  
      |            ^
gondola.cpp:74:2: error: extended character   is not valid in an identifier
   74 |       fixed=true;
      |  ^
gondola.cpp:74:5: error: extended character   is not valid in an identifier
   74 |       fixed=true;
      |    ^
gondola.cpp:74:8: error: extended character   is not valid in an identifier
   74 |       fixed=true;
      |      ^
gondola.cpp:76:5: error: extended character   is not valid i