Test instructions
Given the number of N, the number of outputs to reorder and the number of each
1.MAP implementations
#pragma GCC optimize ("O2") #include <iostream> #include <cstdio> #include <cstring> #include < algorithm> #include <cmath> #include <queue> #include <stack> #include <set> #include <map > #include <limits.h> #include <ctime> #define N 100001typedef long long ll;const int inf=999999999;const int maxn=2017;using namespace Std;inline int Read () { int f=1,x=0;char ch=getchar (); while (ch> ' 9 ' |ch< ' 0 ') { if (ch== '-') f=-1; Ch=getchar (); } while (ch<= ' 9 ' &&ch>= ' 0 ') { x= (x<<3) + (x<<1) +ch-' 0 '; Ch=getchar (); } return f*x;} typedef map<int,bool> MP;MP M;int Main () {int n=read (); for (int i=1;i<=n;i++) {int k=read (); m[k]=1;} Cout<<m.size () <<endl;for (Mp::iterator i=m.begin (); I!=m.end (); i++) cout<<i->first<< Endl;}
2.set implementations
#pragma GCC optimize ("O2") #include <iostream> #include <cstdio> #include <cstring> #include < algorithm> #include <cmath> #include <queue> #include <stack> #include <set> #include <map > #include <limits.h> #include <ctime> #define N 100001typedef long long ll;const int inf=999999999;const int maxn=2017;using namespace Std;inline int Read () { int f=1,x=0;char ch=getchar (); while (ch> ' 9 ' |ch< ' 0 ') { if (ch== '-') f=-1; Ch=getchar (); } while (ch<= ' 9 ' &&ch>= ' 0 ') { x= (x<<3) + (x<<1) +ch-' 0 '; Ch=getchar (); } return f*x;} Set<int>s;int Main () { int n=read (); for (int i=1;i<=n;i++) {int k=read (); S.insert (k);} printf ("%d", s.size ()); For (Set<int>::iterator I=s.begin (); I!=s.end (); i++) Cout<<*i<<endl;}
Go Weight + Sort Board (SET+MAP)