結果

問題 No.628 Tagの勢い
ユーザー sggkshiosggkshio
提出日時 2018-07-13 08:31:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,787 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 122,308 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 20:16:19
合計ジャッジ時間 2,682 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>


int main() {
	map<string, int>p;
	int n, m, s;
	int a;
	cin >> n;
	vector<pair<int, string>>w;
	while (n--)
	{
		cin >> a >> m >> s  ;
		string t;
		for (int i = 0; i < m; i++) {
			cin >> t;
			p[t] += s;
			w.push_back(make_pair( p[t],t));
		}
		
	}
	sort(w.begin(), w.end());
	reverse(w.begin(), w.end());
	map<string, bool>y;
	vector<map<int, string>>b;
	vector<int>k;
	int e = 0;
	vector<pair<int, string>>wr;
	for (int i = 0; i < w.size(); i++) {
		vector<pair<string, int>>q;
	//	cout << w[i].second<< endl;
		for (int j = i; j < w.size(); j++) {
			//cout <<w[i].first<<"#"<< w[j].first << endl;
			if (y[w[i].second])continue;
			 if (w[i].first == w[j].first)q.push_back(make_pair(w[j].second,w[j].first));
			else break;
			y[w[j].second] = 1; 
			
			
		}
//		cout << q.size() << endl;
		sort(q.begin(), q.end());
		reverse(q.begin(), q.end());
		for (int j = 0; j < q.size(); j++) {
			wr.push_back(make_pair(q[j].second, q[j].first));
		}
		if (wr.size() > 20)break;
	}
	for(int j=0;j<wr.size();j++)
		for (int i = wr.size() - 1; i > j; i--) {
			if (wr[i].first == wr[i - 1].first&&wr[i].second < wr[i - 1].second)swap(wr[i], wr[i - 1]);
	}


	for (int i = 0; i < wr.size()||i<10; i++) {

		cout << wr[i].second << " " << wr[i].first << endl;
/*if (y[w[i].second])continue;
		
			
		
		

		cout << w[i].second << " " << w[i].first << endl;
		
		y[w[i].second] = 1;
		*/
	}

	return 0;
}
0