Submission #1501652
Source Code Expand
#include<cstdio> #include<algorithm> #include<functional> #include<cstring> using namespace std; int main(void) { int n,i,j,c1,c2,mn,x1,x2,cnt; char s[101]; scanf("%d",&n); scanf("%s",s); cnt=0; mn=0; for(i=0;i<n;i++) { if(s[i]=='(') cnt++; else { cnt--; if(cnt<mn) mn=cnt; } } x1=-mn; x2=cnt+x1; for(i=0;i<x1;i++) printf("("); for(i=0;i<n;i++) printf("%c",s[i]); for(i=0;i<x2;i++) printf(")"); printf("\n"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Insertion |
User | laf2 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 472 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:10:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:11:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",s); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 1 ms | 128 KB |
in2.txt | AC | 1 ms | 128 KB |
in3.txt | AC | 1 ms | 128 KB |
in4.txt | AC | 1 ms | 128 KB |
in5.txt | AC | 1 ms | 128 KB |
in6.txt | AC | 1 ms | 128 KB |
in7.txt | AC | 1 ms | 128 KB |
in8.txt | AC | 1 ms | 128 KB |
in9.txt | AC | 1 ms | 128 KB |
s1.txt | AC | 1 ms | 128 KB |
s2.txt | AC | 1 ms | 128 KB |
s3.txt | AC | 1 ms | 128 KB |