Submission #169027


Source Code Expand

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b!=0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   if(n==0||n==1) return false;
   vector<bool> a(n+1);
   fill(ALL(a),true);
   FOR(i,2,n/2+1){
      if(!a[i]) continue;
      for(int j=2;i*j<=n;j++){
         a[i*j]=false;
      }
   }
   return a[n];
}

int main(){
   int n;
   VI t;
   vector<string> s;
   string a;
   int max=-1;
   int ans;
   
   cin >> n;
   REP(i,n){
      cin >> a;
      REP(j,s.size()){
         if(s[j]==a){
            t[j]++;
            //a.clear();
            if(max<t[j]) {
               ans=j;
               max=t[j];
            }
         }
      }
      if(!a.empty()){
         s.PB(a);
         t.PB(0);
         if(max<t[s.size()-1]){
            ans=i;
            max=0;
         }
      }
   }
   cout << s[ans] << endl;
}

Submission Info

Submission Time
Task B - 投票
User menphim
Language C++ (G++ 4.6.4)
Score 100
Code Size 2915 Byte
Status AC
Exec Time 23 ms
Memory 924 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, case_01.txt, case_02.txt, case_03.txt, case_04.txt, case_05.txt, case_06.txt, case_07.txt, case_08.txt, case_09.txt, case_10.txt, case_11.txt, case_12.txt, case_13.txt, case_14.txt, case_15.txt
Case Name Status Exec Time Memory
case_01.txt AC 21 ms 924 KB
case_02.txt AC 23 ms 800 KB
case_03.txt AC 21 ms 788 KB
case_04.txt AC 22 ms 796 KB
case_05.txt AC 22 ms 920 KB
case_06.txt AC 20 ms 840 KB
case_07.txt AC 21 ms 800 KB
case_08.txt AC 22 ms 924 KB
case_09.txt AC 22 ms 916 KB
case_10.txt AC 22 ms 920 KB
case_11.txt AC 22 ms 796 KB
case_12.txt AC 22 ms 716 KB
case_13.txt AC 21 ms 920 KB
case_14.txt AC 22 ms 796 KB
case_15.txt AC 22 ms 916 KB
sample_01.txt AC 21 ms 792 KB
sample_02.txt AC 23 ms 796 KB
sample_03.txt AC 19 ms 716 KB