結果
| 問題 | No.457 (^^*) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-04 06:10:33 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 2,000 ms |
| + 667µs | |
| コード長 | 898 bytes |
| 記録 | |
| コンパイル時間 | 3,059 ms |
| コンパイル使用メモリ | 182,096 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-11-04 06:10:39 |
| 合計ジャッジ時間 | 5,766 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
ll f(string s){
ll ans=0;
vector<int> eye, left, ch;
int n=s.size();
int pose=-1, ci=-1, li=-1, posc=-1;
for(int i=0; i<n; i++){
if(s[i]=='*') ch.push_back(i);
else if(s[i]=='(') left.push_back(i);
else if(s[i]=='^'){
eye.push_back(i);
int x=eye.size();
if(x>=2) pose=eye[x-2];
}
else{
int m=ch.size();
while(ci+1<m&&ch[ci+1]<pose) ci++, posc=ch[ci];
m=left.size();
while(li+1<m&&left[li+1]<posc) li++;
//printf("%d %d %d\n", li, posc, pose);
if(li>=0) ans+=li+1;
}
}
return ans;
}
int main(void){
string s; cin >> s;
for(int i=0; i<2; i++){
reverse(begin(s), end(s));
for(auto&x:s){
if(x==')') x='(';
else if(x=='(') x=')';
}
cout << f(s) << " \n"[i];
}
return 0;
}