結果
問題 | No.945 YKC饅頭 |
ユーザー |
![]() |
提出日時 | 2019-12-08 05:06:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 663 ms / 2,000 ms |
コード長 | 1,816 bytes |
コンパイル時間 | 1,775 ms |
コンパイル使用メモリ | 173,248 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 15:18:49 |
合計ジャッジ時間 | 15,035 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 74 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> l(m), r(m); vector<char> t(m), s(n), s_macro(n / 1000 + 1); for (int i = 0; i < m; i++) { cin >> l.at(i) >> r.at(i) >> t.at(i); l.at(i)--; } reverse(l.begin(), l.end()); reverse(r.begin(), r.end()); reverse(t.begin(), t.end()); for (int i = 0; i < m; i++) { int l_macro = (l.at(i) - 1) / 1000 + 1, r_macro = r.at(i) / 1000; for (int j = l_macro; j < r_macro; j++) { if (j >= n / 1000 + 1) continue; s_macro.at(j) = t.at(i); } if (l_macro >= 1 && s_macro.at(l_macro - 1)) { for (int j = 1000 * (l_macro - 1); j < 1000 * l_macro; j++) { if (j >= n) continue; s.at(j) = s_macro.at(l_macro - 1); } s_macro.at(l_macro - 1) = 0; } if (s_macro.at(r_macro)) { for (int j = 1000 * r_macro; j < 1000 * (r_macro + 1); j++) { if (j >= n) continue; s.at(j) = s_macro.at(r_macro); } s_macro.at(r_macro) = 0; } for (int j = l.at(i); j < 1000 * l_macro; j++) { if (j >= r.at(i)) continue; s.at(j) = t.at(i); } for (int j = 1000 * r_macro; j < r.at(i); j++) { if (j < l.at(i)) continue; s.at(j) = t.at(i); } } for (int i = 0; i < n; i++) { if (s_macro.at(i / 1000)) { s.at(i) = s_macro.at(i / 1000); } } int y = 0, k = 0, c = 0; for (char x : s) { switch (x) { case 'Y': y++; break; case 'K': k++; break; case 'C': c++; break; } } cout << y << " " << k << " " << c << endl; }