結果
| 問題 |
No.2924 <===Super Spaceship String===>
|
| コンテスト | |
| ユーザー |
たごころ
|
| 提出日時 | 2024-10-12 16:59:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,668 bytes |
| コンパイル時間 | 1,370 ms |
| コンパイル使用メモリ | 134,480 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-12 17:00:00 |
| 合計ジャッジ時間 | 3,198 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 1 |
| other | AC * 10 RE * 1 |
ソースコード
#include <iostream>
#include <cmath>
#include <stack>
#include <iomanip>
#include <limits>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<deque>
using namespace std;
#define rep(i, n) for (int i = 0;i < (n); ++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<ll,ll>;
void chmin(ll &a,ll b){
a = min(a,b);
}
void chmax(int &a,int b){
a = max(a,b);
}
const ll INF = 2e18;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
int n = s.size();
vector<int> v(n);
int now = 0;
vector<bool> co(n,true);
vector<bool> judge(n,true);
vector<char> st;
rep(i,n){
st.push_back(s[i]);
if(s[i] == '<'){
now++;
}
else if(s[i] == '>'){
if(!judge[now])continue;
if(v[now] == 0){
v[now] = 0;
now--;
if(now != 0)judge[now] = false;
if(now == 0)judge = co;
}
else{
if(now == 0)continue;
int cnt = v[now]+2;
for(int i = 0;i < cnt;i++){
st.pop_back();
}
v[now] = 0;
now--;
}
}
else{
v[now]++;
}
}
cout << st.size() << endl;
}
たごころ