結果
問題 |
No.3143 Colorless Green Parentheses Sleep Furiously
|
ユーザー |
![]() |
提出日時 | 2025-05-16 21:41:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,857 bytes |
コンパイル時間 | 3,175 ms |
コンパイル使用メモリ | 276,584 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-17 00:23:08 |
合計ジャッジ時間 | 8,331 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 26 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto& i:a) #define ff first #define ss second #define all(a) begin(a),end(a) #define allr(a) rbegin(a),rend(a) #define pb push_back using ll =long long; using pii=pair<int,int>; using pll=pair<ll,ll>; using vi=vector<int>; using vll=vector<ll>; template<class T> inline bool chmin(T& a,T b){return a>b?a=b,1:0;} template<class T> inline bool chmax(T& a,T b){return a<b?a=b,1:0;} const int INFI=numeric_limits<int>::max()/2; const ll INFL=numeric_limits<ll>::max()/2; void solve(){ } int main(){ int n,k;cin>>n>>k; string s;cin>>s; { int cur{}; rep(i,0,n){ if(s[i]=='(')cur++; else cur--; if(cur<0){ cout<<"No"<<endl; return 0; } } } string ans; int cur=0; int sum{}; int flag=0; rep(i,0,n){ if(s[i]=='(')cur++; else cur--; if(s[i]==')'){ if(s[i-1]=='('){ ans.pb('1');ans.pb('+');ans.pb('1'); sum+=2; }else{ ans.pb('+');ans.pb('1'); sum++; } ans.pb(')'); }else{ ans.pb('('); } if(cur==0){ if(i!=n-1){ ans.pb('+'); flag=1; } else{ if(!flag){ ans.pb('+'); ans.pb('1'); sum++; } } } } while(sum<k){ ans.pb('+');ans.pb('1');sum++; } //cout<<ans<<endl; if(sum==k){ cout<<"Yes"<<endl; cout<<ans<<endl; }else{ cout<<"No"<<endl; } return 0; } /* */