結果
問題 |
No.945 YKC饅頭
|
ユーザー |
|
提出日時 | 2020-07-26 14:35:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 559 bytes |
コンパイル時間 | 1,926 ms |
コンパイル使用メモリ | 192,648 KB |
最終ジャッジ日時 | 2025-01-12 05:54:58 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 74 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:16:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | int n,q; scanf("%d%d",&n,&q); | ~~~~~^~~~~~~~~~~~~~ main.cpp:22:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | char c; scanf("%d%d %c",&l,&r,&c); l--; | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int color[200000],nxt[200000]; int go(int i,int r,int c){ if(i>=r) return i; if(color[i]==0) color[i]=c; return nxt[i]=go(nxt[i],r,c); } int main(){ int n,q; scanf("%d%d",&n,&q); rep(i,n) nxt[i]=i+1; rep(_,q){ int l,r; char c; scanf("%d%d %c",&l,&r,&c); l--; go(l,r,c); } int ans[3]={}; rep(i,n){ if(color[i]=='Y') ans[0]++; if(color[i]=='K') ans[1]++; if(color[i]=='C') ans[2]++; } rep(i,3) printf("%d%c",ans[i],i<2?' ':'\n'); return 0; }