답안 #1017660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017660 2024-07-09T09:23:34 Z vivkostov 곤돌라 (IOI14_gondola) C++14
60 / 100
12 ms 7772 KB
#include<bits/stdc++.h>
#define endl '\n'
#include "gondola.h"
using namespace std;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
struct cell
{
    int v,st;
};
bool cmp(cell a1,cell a2)
{
    return a1.st<a2.st;
}
int n,a[200005],used[1000005],ind[200005];
cell c[200005];
int valid(int n,int seq[])
{
    int br=0;
    for(int i=1;i<=n;i++)
    {
        a[i]=seq[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=n)
        {
            if(!br)br=a[i];
            else
            {
                if(a[i]!=br)
                {
                    return 0;
                }
            }
        }
        if(used[a[i]])
        {
            return 0;
        }
        used[a[i]]=1;
        if(br)br++;
        if(br>n)br=1;
    }
    for(int i=n+2;i<=250000;i++)
    {
        if(used[i]&&!used[i-1])
        {
            return 0;
        }
    }
    return 1;
}
int replacement(int n, int seq[], int rseq[])
{
    int st=1,val=1,next=n+1;
    for(int i=1;i<=n;i++)
    {
        a[i]=seq[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=n)
        {
            st=i;
            val=a[i];
            break;
        }
    }
    for(int i=st;i<=n;i++)
    {
        ind[i]=val;
        val++;
        if(val>n)val=1;
    }
    for(int i=1;i<st;i++)
    {
        ind[i]=val;
        val++;
    }
    for(int i=1;i<=n;i++)
    {
        c[i].v=ind[i];
        c[i].st=a[i];
    }
    sort(c+1,c+n+1,cmp);
    int br=0;
    for(int i=1;i<=n;i++)
    {
        if(c[i].st>n)
        {
            while(c[i].v!=c[i].st)
            {
                rseq[br]=c[i].v;
                br++;
                c[i].v=next;
                next++;
            }
        }
    }
    return br;
}
long long int fup(long long int base,long long int pow)
{
    long long int otg=1;
    for(int i=0;i<=30;i++)
    {
        if(pow&(1<<i))
        {
            otg*=base;
            otg=otg%1000000009;
        }
        base*=base;
        base=base%1000000009;
    }
}
int countReplacement(int n, int seq[])
{
    long long int br=1,now=n;
    for(int i=1;i<=n;i++)
    {
        a[i]=seq[i-1];
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        if(a[i]>n)
        {
            br=br*fup(n-i+1,a[i]-now-1);
            br=br%1000000009;
            now=a[i];
        }
    }
    if(!valid(n,seq))return 0;
    return br;
}
/*int main()
{
    speed();
    read();
    return 0;
}
*/

Compilation message

gondola.cpp: In function 'long long int fup(long long int, long long int)':
gondola.cpp:120:1: warning: no return statement in function returning non-void [-Wreturn-type]
  120 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4552 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 3 ms 4700 KB Output is correct
7 Correct 6 ms 4444 KB Output is correct
8 Correct 5 ms 4700 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 6 ms 4796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 3 ms 4700 KB Output is correct
7 Correct 8 ms 4444 KB Output is correct
8 Correct 7 ms 4700 KB Output is correct
9 Correct 3 ms 4444 KB Output is correct
10 Correct 7 ms 4700 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4536 KB Output is correct
13 Correct 3 ms 4700 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 6 ms 4536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 10 ms 6748 KB Output is correct
12 Correct 11 ms 6748 KB Output is correct
13 Correct 10 ms 7004 KB Output is correct
14 Correct 11 ms 6748 KB Output is correct
15 Correct 12 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Incorrect 1 ms 4444 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Incorrect 1 ms 4444 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4536 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Incorrect 1 ms 4440 KB Output isn't correct
6 Halted 0 ms 0 KB -