답안 #902801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902801 2024-01-11T03:03:58 Z Sir_Ahmed_Imran 곤돌라 (IOI14_gondola) C++17
60 / 100
27 ms 4204 KB
                              ///~~~LOTA~~~///
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define MAXN 250001
ll mod=1e9+7;
int vis[MAXN];
int valid(int n, int a[]){
    for(int i=0;i<n;i++){
        if(a[i]>n) continue;
        vis[a[i]]=1;
        for(int j=i+1;j<i+n;j++){
            if(vis[a[j%n]]) return 0;
            vis[a[j%n]]=1;
            if(a[j%n]>n) continue;
            if(a[j%n]!=1+((a[i]+j-i-1)%n)) return 0;
        }
        return 1;
    }
    for(int i=0;i<n;i++){
        if(vis[a[i]]) return 0;
        vis[a[i]]=1;
    }
    return 1;
}
int replacement(int n,int a[],int v[]){
    int m,o;
    set<pii> s;
    for(int i=m=o=0;i<n;i++){
        m=max(m,a[i]);
        if(a[i]>n) continue;
        for(int j=i+1;j<i+n;j++){
            m=max(m,a[j%n]);
            if(a[j%n]>n)
                s.insert({a[j%n],1+((a[i]+j-i-1)%n)});
        }
        o=1;
        break; 
    }
    pii pi;
    if(!o)
        for(int i=0;i<n;i++)
            s.insert({a[i],i+1});
    o=0;
    for(int i=n+1;i<=m;i++){
        pi=*s.begin();
        s.erase(s.begin());
        v[o]=pi.ss;
        pi.ss=i;
        o++;
        if(pi.ss!=pi.ff) 
            s.insert(pi);
    }
    return o;
}
int countReplacement(int n,int a[]){
    if(!valid(n,a)) return 0;
    int m;
    set<int> s;
    for(int i=m=0;i<n;i++){
        m=max(m,a[i]);
        if(a[i]>n) s.insert(a[i]); 
    }
    ll o=1;
    for(int i=n+1;i<=m;i++){
        if(*s.begin()==i) 
            s.erase(s.begin());
        else o=(o*s.size())%mod;
    }
    return o;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2400 KB Output is correct
6 Correct 5 ms 2408 KB Output is correct
7 Correct 6 ms 2408 KB Output is correct
8 Correct 8 ms 2664 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 7 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2396 KB Output is correct
7 Correct 6 ms 2396 KB Output is correct
8 Correct 6 ms 2488 KB Output is correct
9 Correct 4 ms 2396 KB Output is correct
10 Correct 11 ms 2652 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 3 ms 2408 KB Output is correct
14 Correct 1 ms 2408 KB Output is correct
15 Correct 8 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2408 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 1 ms 2660 KB Output is correct
4 Correct 1 ms 2408 KB Output is correct
5 Correct 0 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2408 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 1 ms 2408 KB Output is correct
4 Correct 1 ms 2408 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 0 ms 2408 KB Output is correct
7 Correct 1 ms 2408 KB Output is correct
8 Correct 1 ms 2408 KB Output is correct
9 Correct 2 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 10 ms 2488 KB Output is correct
12 Correct 7 ms 2396 KB Output is correct
13 Correct 17 ms 4168 KB Output is correct
14 Correct 10 ms 2392 KB Output is correct
15 Correct 27 ms 4204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2492 KB Output is correct
3 Correct 1 ms 2492 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Incorrect 1 ms 2492 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2496 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Incorrect 1 ms 2396 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Incorrect 1 ms 2396 KB Output isn't correct
8 Halted 0 ms 0 KB -