結果
問題 | No.2590 100000 Days of Christmas |
ユーザー |
|
提出日時 | 2023-12-18 05:32:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 229 ms / 2,000 ms |
コード長 | 728 bytes |
コンパイル時間 | 1,844 ms |
コンパイル使用メモリ | 177,724 KB |
実行使用メモリ | 13,696 KB |
最終ジャッジ日時 | 2024-09-27 08:15:07 |
合計ジャッジ時間 | 4,506 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#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; }