⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keys.cpp

📁 Central European Olympiad in Informatics Collection of solutions...
💻 CPP
字号:
/*
Alfonso Alfonso Peterssen
6 - 3 - 2008
CEOI 2005 "Keys"
*/
#include <cstdio>
#include <algorithm>

using std::sort;

const int MAXC = 1000000 + 1;

int n, c, x, len;
int last[MAXC];
int sol[MAXC];

bool comp( const int &i, const int &j ) {
    return last[i] < last[j];
}

int main() {

    scanf( "%d %d", &c, &n );
    while ( n-- ) {
        scanf( "%d", &x );
        if ( !last[x] ) sol[len++] = x;
        last[x] = n + 1;
    }
    
    sort( sol, sol + len, comp );

    printf( "%d\n", len );
    while ( len-- )
        printf( len ? "%d " : "%d\n", sol[len] );

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -