Submission #42510709


Source Code Expand

#include<cstdio>
using namespace std;
#define Ls(i,l,r) for(int i=l;i<r;++i)
#define Rs(i,l,r) for(int i=l;i>r;--i)
#define Le(i,l,r) for(int i=l;i<=r;++i)
#define Re(i,l,r) for(int i=l;i>=r;--i)
#define L(i,l) for(int i=0;i<l;++i)
#define E(i,l) for(int i=1;i<=l;++i)
#define W(t) while(t--)
const int N=200010;
int n,a[N],r[N],m,top,st[N],in[N];
int main(){
    #ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
    // freopen("1.out","w",stdout);
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    #endif
    // Insert Code Here
    scanf("%d%d",&n,&m);
    E(i, n)scanf("%d",a+i),r[a[i]]=i;
    E(i, n){
        if(in[a[i]])continue;
        in[a[i]]=1;
        while(top&&st[top]>a[i]&&r[st[top]]>i)in[st[top]]=0,--top;
        st[++top]=a[i];
    }
    E(i, top)printf("%d ",st[i]);
    return 0;
}

Submission Info

Submission Time
Task G - Minimum Permutation
User WUSICHENG
Language C++ (GCC 9.2.1)
Score 600
Code Size 860 Byte
Status AC
Exec Time 49 ms
Memory 4780 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   21 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
./Main.cpp:22:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   22 |     E(i, n)scanf("%d",a+i),r[a[i]]=i;
      |            ~~~~~^~~~~~~~~~

Judge Result

Set Name Sample All AfterContest
Score / Max Score 0 / 0 600 / 600 0 / 0
Status
AC × 3
AC × 47
AC × 1
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_max_03.txt, 01_max_04.txt, 01_max_05.txt, 01_max_06.txt, 01_max_07.txt, 01_max_08.txt, 01_max_09.txt, 01_max_10.txt, 01_max_11.txt, 01_max_12.txt, 01_max_13.txt, 01_max_14.txt, 01_max_15.txt, 01_max_16.txt, 01_max_17.txt, 01_max_18.txt, 01_max_19.txt, 01_max_20.txt, 01_max_21.txt, 01_max_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt, 02_random_26.txt, 02_random_27.txt, 02_random_28.txt, 02_random_29.txt, 02_random_30.txt, 02_random_31.txt, 02_random_32.txt, 02_random_33.txt, 02_random_34.txt, 02_random_35.txt, 02_random_36.txt, 02_random_37.txt, 02_random_38.txt, 03_handmade_39.txt, 03_handmade_40.txt, 03_handmade_41.txt, 03_handmade_42.txt, 03_handmade_43.txt, 03_handmade_44.txt, 03_handmade_45.txt, 03_handmade_46.txt
AfterContest 04_after_contest_47.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 5 ms 1636 KiB
00_sample_01.txt AC 1 ms 1708 KiB
00_sample_02.txt AC 1 ms 1648 KiB
01_max_03.txt AC 23 ms 2476 KiB
01_max_04.txt AC 19 ms 2448 KiB
01_max_05.txt AC 18 ms 2420 KiB
01_max_06.txt AC 19 ms 2480 KiB
01_max_07.txt AC 19 ms 2492 KiB
01_max_08.txt AC 27 ms 2424 KiB
01_max_09.txt AC 23 ms 2456 KiB
01_max_10.txt AC 21 ms 2424 KiB
01_max_11.txt AC 22 ms 2416 KiB
01_max_12.txt AC 23 ms 2420 KiB
01_max_13.txt AC 36 ms 3584 KiB
01_max_14.txt AC 40 ms 3588 KiB
01_max_15.txt AC 39 ms 3584 KiB
01_max_16.txt AC 42 ms 3592 KiB
01_max_17.txt AC 40 ms 3584 KiB
01_max_18.txt AC 49 ms 4776 KiB
01_max_19.txt AC 49 ms 4780 KiB
01_max_20.txt AC 47 ms 4752 KiB
01_max_21.txt AC 49 ms 4748 KiB
01_max_22.txt AC 47 ms 4744 KiB
02_random_23.txt AC 18 ms 2488 KiB
02_random_24.txt AC 18 ms 2408 KiB
02_random_25.txt AC 18 ms 2412 KiB
02_random_26.txt AC 26 ms 2428 KiB
02_random_27.txt AC 30 ms 2500 KiB
02_random_28.txt AC 27 ms 2444 KiB
02_random_29.txt AC 18 ms 2184 KiB
02_random_30.txt AC 28 ms 3132 KiB
02_random_31.txt AC 21 ms 2432 KiB
02_random_32.txt AC 25 ms 2552 KiB
02_random_33.txt AC 32 ms 2980 KiB
02_random_34.txt AC 4 ms 1652 KiB
02_random_35.txt AC 28 ms 2304 KiB
02_random_36.txt AC 1 ms 1636 KiB
02_random_37.txt AC 29 ms 2720 KiB
02_random_38.txt AC 16 ms 2092 KiB
03_handmade_39.txt AC 1 ms 1668 KiB
03_handmade_40.txt AC 20 ms 2416 KiB
03_handmade_41.txt AC 29 ms 3116 KiB
03_handmade_42.txt AC 36 ms 3624 KiB
03_handmade_43.txt AC 44 ms 4776 KiB
03_handmade_44.txt AC 6 ms 1640 KiB
03_handmade_45.txt AC 2 ms 1668 KiB
03_handmade_46.txt AC 24 ms 2488 KiB
04_after_contest_47.txt AC 37 ms 3592 KiB