답안 #243810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243810 2020-07-01T20:15:11 Z aloo123 곤돌라 (IOI14_gondola) C++14
20 / 100
354 ms 262148 KB
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <gondola.h>
#define ll int
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
// #define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
 
 
const ll INF = 1e18;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;


int valid(int n, int a[]){
    bool done[n+1];
    ll spare = n+1;
    set<ll> se;
    ll nxt = a[0];
    se.in(nxt);
    nxt++;
    if(nxt > n) nxt = 1;
    // ll spare =n;
    for(int i = 1;i<n;i++){
        if(se.find(a[i]) != se.end()) return 0;
        if(a[i] <= n){
            if(a[i] != nxt) return 0;
            se.in(a[i]);
        }
        else{
            if(a[i] < spare){
                return 0;           
            }
            spare = a[i];
        }
        nxt++;
        if(nxt > n) nxt = 1;
    }
    return 1;
}
int replacement(int n, int a[], int replacementSeq[]) {
    ll idx = 0;
    bool original = 0;
    for(int i =0;i<n;i++){
        if(a[i] <= n){
            idx =i;
            original = true;
            break;
        }
    }
 
    int b[n];
    for(int i =0;i<n;i++){
        if(a[i] <= n){
            b[i] = a[i];
        }
    }
    vector<int> ans;
    vector<pair<int,int>> gg;
    ll count = 1;
    ll nxt = a[idx];
    if(original == false) nxt = 1; 
    // cout << idx << endl;
    while(count <= n){
        
            b[idx] = nxt;
            nxt++;
            idx++;
            if(nxt > n) nxt = 1;
            if(idx >= n) idx = 0;
            count++;
        
    }
    ll sp = n+1;
    // for(int i =0;i<n;i++) cout << b[i] << " ";cout<<endl;
    for(int i =0;i<n;i++){
        gg.pb({b[i],a[i]});
    }
    sort(gg.begin(),gg.end());
    for(int i = 0;i<sz(gg);i++){
        ans.pb(gg[i].f);
        ll x = sp;
        while(x != gg[i].s){
            ans.pb(x);
            x++;
        }
        sp = gg[i].s+1;
        
    }
    // for(int i = 0;i<sz(ans);i++) cout<<ans[i]<<" ";cout<<endl;
    for(int i = 0;i<sz(ans);i++) replacementSeq[i] = ans[i];
    return sz(ans);

}
int countReplacement(int n, int inputSeq[]) {return -3;}

Compilation message

gondola.cpp:54:16: warning: overflow in implicit constant conversion [-Woverflow]
 const ll INF = 1e18;
                ^~~~
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:60:10: warning: unused variable 'done' [-Wunused-variable]
     bool done[n+1];
          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 19 ms 2176 KB Output is correct
7 Correct 17 ms 640 KB Output is correct
8 Correct 32 ms 3968 KB Output is correct
9 Correct 13 ms 1536 KB Output is correct
10 Correct 43 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 19 ms 2304 KB Output is correct
7 Correct 17 ms 640 KB Output is correct
8 Correct 33 ms 3960 KB Output is correct
9 Correct 12 ms 1536 KB Output is correct
10 Correct 40 ms 4520 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 10 ms 512 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 18 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 325 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 319 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 354 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 308 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -