Submission #169029


Source Code Expand

#include <iostream>
#include <iomanip>  // setw
#include <algorithm> // sort next_permutation count __gcd reverse etc.
#include <set>
#include <list>
#include <map>
#include <memory>
#include <numeric> // accumulate
#include <functional>
#include <utility>
#include <iterator>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <fstream> // freopen
#include <cstdio> // scanf printf
#include <cstdlib> // abs exit atof atoi
#include <string> // memset
#include <cstring>
#include <cmath> // fabs
#include <cctype> // tolower toupper
#include <sstream> // stringstream
#include <bitset>

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rer(i,n) for(int i=1; i<=n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreb(i,n,b) for(int i = n; i >= b; i--)
#define resz(i,v) rep(i,sz(v))
#define let(v, x) __typeof(x) v = (x)
#define each(it,v) for(let(it, (v).begin()); it!=(v).end(); it++)
#define reach(it,v) for(let(it, (v).rbegin());i!=(v).rend();i++)
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES

using std::stringstream;
using namespace std;

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
/* --------------------------------------------------------------- */

int main(int argc, char *argv[])
{
//    ios::sync_with_stdio(false);
//    cin.tie(0); // off the synchronous of cin and cout
    int n;
    cin >> n;
    vector<pair<string, int> > s;
    //    pair<string, int> s[n];
    rep(i, n) {
        bool f=false;
        string t;
        cin >> t;
        rep(j, sz(s)) {
            if (s[j].fi == t) {
                s[j].se++;
                f=true;
            }
        }
        if (!f) s.pb(mp(t, 0));
    }

    pair<int, int> t;
    t.fi=t.se=-1;
    rep(i, sz(s)) {
        if (t.fi < s[i].se) {
            t.fi = s[i].se;
            t.se = i;
        }
    }

// rep(i, n) {
//     cout << s[i].fi << s[i].se << endl;
// }
    cout << s[t.se].fi << endl;
    return 0;
}

Submission Info

Submission Time
Task B - 投票
User emacs
Language C++ (G++ 4.6.4)
Score 100
Code Size 3507 Byte
Status AC
Exec Time 36 ms
Memory 1048 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 25 ms 1044 KB
case_02.txt AC 26 ms 996 KB
case_03.txt AC 25 ms 1048 KB
case_04.txt AC 24 ms 932 KB
case_05.txt AC 23 ms 932 KB
case_06.txt AC 26 ms 1036 KB
case_07.txt AC 25 ms 956 KB
case_08.txt AC 36 ms 892 KB
case_09.txt AC 24 ms 1048 KB
case_10.txt AC 24 ms 936 KB
case_11.txt AC 25 ms 1044 KB
case_12.txt AC 27 ms 1044 KB
case_13.txt AC 25 ms 928 KB
case_14.txt AC 24 ms 1040 KB
case_15.txt AC 23 ms 932 KB
sample_01.txt AC 24 ms 1028 KB
sample_02.txt AC 24 ms 960 KB
sample_03.txt AC 25 ms 920 KB