Submission #707102

#TimeUsernameProblemLanguageResultExecution timeMemory
707102Alihan_8Gondola (IOI14_gondola)C++17
20 / 100
44 ms6468 KiB
#include <bits/stdc++.h>
#include "gondola.h"
// include <ext/pb_ds/assoc_container.hpp>
// include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
// define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define mpr make_pair
#define ln '\n'
void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
//#define int long long
int valid(int n, int inputSeq[]){
    vector <int> p;
    for ( int i = 0; i < n; i++ ) p.pb(inputSeq[i]);
    map <int,int> mp;
    for ( auto i: p ){
        if ( mp.count(i) ) return false;
        mp[i] = true;
    }
    vector <pair<int,int>> res;
    for ( int i = 0; i < n; i++ ){
        if ( p[i] <= n ) res.pb({p[i], i});
    }
    sort(all(res));
    for ( int i = 1; i < (int)res.size(); i++ ){
        auto [x, y] = res[i-1];
        auto [l, r] = res[i];
        r = (r+n-y)%n;
        if ( l-x != r ) return false;
    }
    return true;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]){

}
int countReplacement(int n, int inputSeq[]){

}
#if false
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int sub_task, n; cin >> n;
    int p[n];
    for ( int i = 0; i < n; i++ ) cin >> p[i];
    cout << valid(n, p);

    cout << '\n';
/*
Case #1
7
2 3 4 9 6 7 1
answer: 1
5
10 4 3 11 12
answer: 0
*/
}
#endif

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
   37 | }
      | ^
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
gondola.cpp: In function 'void IO(std::string)':
gondola.cpp:12:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gondola.cpp:12:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...