Submission #582223

#TimeUsernameProblemLanguageResultExecution timeMemory
582223jasminGondola (IOI14_gondola)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include<gondola.h>
using namespace std;

const int inf=1e9;

vector<int> reorder(int n, vector<int> s){
    int small=inf; int ind=-1;
    for(int i=0; i<n; i++){
        if(s[i]<small){
            small=s[i];
            ind=i;
        }
    }

    if(n<small){
        return s;
    }
    int start=(n+ind-(small-1))%n;
    vector<int> ans(n);
    for(int i=0; i<n; i++){
        ans[i]=s[(start+i)%n];
    }
    return ans;
}

bool valid(int n, signed s[]){
    s=reorder(n, s);
    set<int> used;
    for(int i=0; i<n; i++){
        if(s[i]!=i+1){
            if(s[i]<=n || used.find(s[i])!=used.end()){
                return false;
            }
            used.insert(s[i]);
        }
    }
    return true;
}

/*signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    cout << valid(n, s) << "\n";
}*/

Compilation message (stderr)

gondola.cpp:27:6: error: ambiguating new declaration of 'bool valid(int, int*)'
   27 | bool valid(int n, signed s[]){
      |      ^~~~~
In file included from gondola.cpp:2:
gondola.h:8:5: note: old declaration 'int valid(int, int*)'
    8 | int valid(int n, int inputSeq[]);
      |     ^~~~~
gondola.cpp: In function 'bool valid(int, int*)':
gondola.cpp:28:18: error: could not convert 's' from 'int*' to 'std::vector<int>'
   28 |     s=reorder(n, s);
      |                  ^
      |                  |
      |                  int*