답안 #902803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902803 2024-01-11T03:05:22 Z Sir_Ahmed_Imran 곤돌라 (IOI14_gondola) C++17
75 / 100
31 ms 5724 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+9;
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 2400 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 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
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 5 ms 2500 KB Output is correct
7 Correct 6 ms 2396 KB Output is correct
8 Correct 6 ms 2652 KB Output is correct
9 Correct 3 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 2392 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2400 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 4 ms 2392 KB Output is correct
7 Correct 11 ms 2488 KB Output is correct
8 Correct 7 ms 2648 KB Output is correct
9 Correct 3 ms 2396 KB Output is correct
10 Correct 10 ms 2652 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 3 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 6 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 0 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 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 2392 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 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2392 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 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 8 ms 2492 KB Output is correct
12 Correct 7 ms 2396 KB Output is correct
13 Correct 17 ms 4188 KB Output is correct
14 Correct 10 ms 2392 KB Output is correct
15 Correct 31 ms 4280 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 2392 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 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 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
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 24 ms 5720 KB Output is correct
10 Correct 15 ms 4956 KB Output is correct
11 Correct 7 ms 3624 KB Output is correct
12 Correct 14 ms 3956 KB Output is correct
13 Incorrect 3 ms 2652 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2476 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 19 ms 5724 KB Output is correct
10 Correct 22 ms 4956 KB Output is correct
11 Correct 7 ms 3676 KB Output is correct
12 Correct 8 ms 3948 KB Output is correct
13 Incorrect 3 ms 2652 KB Output isn't correct
14 Halted 0 ms 0 KB -