結果

問題 No.2590 100000 Days of Christmas
ユーザー daiotadaiota
提出日時 2023-12-18 05:32:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 176,864 KB
実行使用メモリ 13,696 KB
最終ジャッジ日時 2023-12-18 05:32:30
合計ジャッジ時間 5,366 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 200 ms
13,696 KB
testcase_07 AC 9 ms
6,676 KB
testcase_08 AC 239 ms
13,568 KB
testcase_09 AC 14 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 251 ms
13,568 KB
testcase_21 AC 273 ms
13,568 KB
testcase_22 AC 233 ms
12,928 KB
testcase_23 AC 251 ms
13,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<string,string> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)


ll a[3][100010];

int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;

	ll N;
	cin >> N;
	cin.ignore();

	map<string,ll> m;

	i=1;
	string s;
	while(getline(cin,s)){

		if(m.count(s)!=0LL){
			ll c=m[s];
			a[2][c]+=	(i-1-a[0][c])*a[1][c]+a[1][c]+i;
			a[1][c]+=i;
			a[0][c]=i;
		}
		else{
			m[s]=i;
			a[0][i]=i;
			a[1][i]=i;
			a[2][i]=i;
		}

		if(i==N){

		for(j=1;j<=N;j++){
			if(a[0][j]==N) continue;
			a[2][j]+=(N-a[0][j])*a[1][j];
		}

		for(auto c : m){
			cout << a[2][c.second] << ' ' << c.first  << endl;
		}
		}

		i++;
	}



	return 0;
}
0