結果

問題 No.628 Tagの勢い
ユーザー sggkshiosggkshio
提出日時 2018-07-13 08:30:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,782 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 120,216 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-29 14:22:30
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 19 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 12 ms
4,376 KB
testcase_15 AC 61 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,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() >= 10)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++) {

		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