QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#591395#5534. Matchifffer_21370 0ms3540kbC++14863b2024-09-26 15:45:322024-09-26 15:45:33

Judging History

你现在查看的是最新测评结果

  • [2024-09-26 15:45:33]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3540kb
  • [2024-09-26 15:45:32]
  • 提交

answer

//From: ifffer_2137
#include <bits/stdc++.h>
using namespace std;
#define inf 0x7fffffff
#define eb emplace_back
#define pii pair<int,int>
#define mkpr make_pair
#define fir first
#define sec second
inline int read(){
	char ch=getchar();int x=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-48,ch=getchar();return w==1?x:-x;
}
const int maxn=1e5+5;
int n;
string s;
int stk[maxn],tp;
char ans[maxn];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("data.in","r",stdin);
	freopen("test.out","w",stdout);
	#endif
	cin.tie(0),cout.tie(0);
	cin>>s;n=s.size();s=' '+s;
	for(int i=1;i<=n;i++){
		if(tp&&s[stk[tp]]==s[i]) ans[stk[tp]]='(',tp--,ans[i]=')';
		else stk[++tp]=i;
	}
	if(tp){
		puts("-1");
		return 0;
	}
	for(int i=1;i<=n;i++) cout<<ans[i];
	cout<<"\n";
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3540kb

input:

abbaaa

output:

(())()

result:

wrong answer 1st lines differ - expected: '(()())', found: '(())()'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%