結果
| 問題 |
No.2924 <===Super Spaceship String===>
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 15:52:32 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,079 bytes |
| コンパイル時間 | 2,856 ms |
| コンパイル使用メモリ | 130,456 KB |
| 実行使用メモリ | 14,420 KB |
| 最終ジャッジ日時 | 2024-10-12 15:52:44 |
| 合計ジャッジ時間 | 3,449 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 WA * 5 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>
#include <set>
#include <map>
#include <cassert>
using namespace std;
struct MyChar {
char c;
int cnt;
MyChar(char _c){
c = _c;
cnt = 1;
}
};
int main() {
string s;
cin >> s;
string t;
vector<MyChar> v;
for (char c: s) {
if (v.empty()) {
v.emplace_back(c);
} else {
if (v.back().c == '=' && c == '=') {
v.back().cnt++;
} else {
v.emplace_back(c);
}
}
}
auto show = [](vector<MyChar> v) -> void {
for (auto mc: v) {
fprintf(stderr, "(%c, %d) ", mc.c, mc.cnt);
}
cout << endl;
// cout << s << endl;
};
vector<MyChar> u;
for (auto mc: v) {
// fprintf(stderr, "-----\n");
// show(u);
u.push_back(mc);
if (u.size() < 3) {
continue;
}
int n = u.size();
if (u[n-3].c == '<' && u[n-2].c == '=' && u[n-1].c == '>') {
u.pop_back();
u.pop_back();
u.pop_back();
}
// show(u);
}
int ans = 0;
for (auto mc: u) {
ans += mc.cnt;
}
cout << ans << endl;
return 0;
}