Submission #21472068


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, K;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	map<string, int> cnt;
	rep(i, 0, N) {
		string s; cin >> s;
		cnt[s]++;
	}

	map<int, vector<string>> rev;
	fore(p, cnt) rev[p.second].push_back(p.first);
	int x = 1;
	for (auto ite = rev.rbegin(); ite != rev.rend(); ite++) {
		vector<string> strs = ite->second;
		int tot = strs.size();

		if (x <= K && K < x + tot) {
			if (strs.size() == 1) cout << strs[0] << endl;
			else cout << "AMBIGUOUS" << endl;
			return;
		}
		x += tot;
	}
}





Submission Info

Submission Time
Task F - 構文解析
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 7
Code Size 1896 Byte
Status AC
Exec Time 86 ms
Memory 17280 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 7 / 7
Status
AC × 3
AC × 43
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All all_different_00.txt, all_different_01.txt, all_different_02.txt, handmade_00.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
all_different_00.txt AC 86 ms 17280 KB
all_different_01.txt AC 51 ms 12268 KB
all_different_02.txt AC 38 ms 8872 KB
handmade_00.txt AC 2 ms 3500 KB
random_00.txt AC 43 ms 5680 KB
random_01.txt AC 32 ms 3748 KB
random_02.txt AC 24 ms 3472 KB
random_03.txt AC 23 ms 3564 KB
random_04.txt AC 19 ms 3564 KB
random_05.txt AC 20 ms 3520 KB
random_06.txt AC 25 ms 4984 KB
random_07.txt AC 31 ms 3748 KB
random_08.txt AC 22 ms 3492 KB
random_09.txt AC 13 ms 3504 KB
random_10.txt AC 16 ms 3540 KB
random_11.txt AC 7 ms 3580 KB
random_12.txt AC 20 ms 4956 KB
random_13.txt AC 34 ms 3748 KB
random_14.txt AC 13 ms 3540 KB
random_15.txt AC 19 ms 3504 KB
random_16.txt AC 13 ms 3472 KB
random_17.txt AC 9 ms 3456 KB
random_18.txt AC 31 ms 5252 KB
random_19.txt AC 7 ms 3804 KB
random_20.txt AC 5 ms 3480 KB
random_21.txt AC 19 ms 3508 KB
random_22.txt AC 13 ms 3496 KB
random_23.txt AC 9 ms 3472 KB
random_24.txt AC 28 ms 5492 KB
random_25.txt AC 14 ms 3804 KB
random_26.txt AC 13 ms 3608 KB
random_27.txt AC 18 ms 3520 KB
random_28.txt AC 15 ms 3432 KB
random_29.txt AC 11 ms 3452 KB
random_30.txt AC 39 ms 5384 KB
random_31.txt AC 16 ms 3736 KB
random_32.txt AC 13 ms 3616 KB
random_33.txt AC 26 ms 3528 KB
random_34.txt AC 6 ms 3452 KB
random_35.txt AC 17 ms 3576 KB
sample_01.txt AC 2 ms 3452 KB
sample_02.txt AC 2 ms 3508 KB
sample_03.txt AC 6 ms 3568 KB