結果
| 問題 |
No.3143 Colorless Green Parentheses Sleep Furiously
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-16 21:30:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 911 bytes |
| コンパイル時間 | 1,853 ms |
| コンパイル使用メモリ | 195,384 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-05-17 00:20:16 |
| 合計ジャッジ時間 | 6,789 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,K; cin >> N >> K;
string s; cin >> s;
int sum = 0,open = 0,back = 0;
for(auto c : s){
if(c == '(') open++,back = 0;
else{
sum++;
if(back == 0) sum++;
open--,back = 1;
}
if(open < 0){cout << "No\n"; return 0;}
}
if(open > 0 || sum > K){cout << "No\n"; return 0;}
cout << "Yes\n";
bool first = true;
for(auto c : s){
if(c == '('){
if(open == 0 && !first) cout << '+';
cout << '(';
back = 0; open++;
}
else{
if(back == 0) cout << '1';
cout << "+1)";
back = 1; open--;
}
first = false;
}
int more = K-sum;
while(more--) cout << "+1";
cout << endl;
}