又一次证明了STL大法好
map+vector+sort一波带走
至于非C++玩家。。大概就是hash了【还有几率冲突233
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
// <count.cpp> - 03/01/16 20:38:46 // This file is created by XuYike's black technology automatically. // Copyright (C) 2015 ChangJun High School, Inc. // I don't know what this program is. #include <iostream> #include <vector> #include <map> #include <algorithm> #include <cstring> #include <cstdio> #include <cmath> using namespace std; typedef long long lol; int getint(){ int res=0,fh=1;char ch=getchar(); while((ch>'9'||ch<'0')&&ch!='-')ch=getchar(); if(ch=='-')fh=-1,ch=getchar(); while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar(); return fh*res; } const int MAXN=200001; map <int,int> mp; vector <int> v; int main(){ freopen("count.in","r",stdin); freopen("count.out","w",stdout); int n=getint(); for(int i=1;i<=n;i++){ int a=getint(); if(!mp[a])v.push_back(a); mp[a]++; } sort(v.begin(),v.end()); for(int i=0;i<v.size();i++)printf("%d %d\n",v[i],mp[v[i]]); return 0; } |
事实上可以手写splay
针拉机