結果
| 問題 |
No.945 YKC饅頭
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-14 22:17:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,489 ms / 2,000 ms |
| コード長 | 1,238 bytes |
| コンパイル時間 | 3,759 ms |
| コンパイル使用メモリ | 200,300 KB |
| 最終ジャッジ日時 | 2025-01-09 19:00:53 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 74 |
ソースコード
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n,m;std::cin>>n>>m;
std::vector<std::tuple<lint,lint,char>>a(m);
for(lint i=0;i<m;i++){
lint l,r;char c;std::cin>>l>>r>>c;l--;
a.at(i)={l,r,c};
}
std::reverse(ALL(a));
lint k=std::sqrt(n);
std::string ans(n,'$'),lazy(n/k+1,'$');
for(auto[l,r,c]:a){
lint L=l/k,R=r/k;
if(lazy.at(L)!='$')for(lint i=L*k;i<(L+1)*k;i++)ans.at(i)=lazy.at(L);
if(lazy.at(R)!='$')for(lint i=R*k;i<(R+1)*k;i++)ans.at(i)=lazy.at(R);
lazy.at(L)=lazy.at(R)='$';
for(;l<r&&l%k;ans.at(l++)=c);
for(;l<r&&r%k;ans.at(--r)=c);
L=l/k,R=r/k;
for(;L<R;lazy.at(L++)=c);
}
for(lint i=0;i<n/k;i++){
if(lazy.at(i)=='$')continue;
for(lint j=i*k;j<(i+1)*k;j++)ans.at(j)=lazy.at(i);
}
std::cout
<<std::count(ALL(ans),'Y')
<<' '<<std::count(ALL(ans),'K')
<<' '<<std::count(ALL(ans),'C')
<<'\n';
}
ngtkana