QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#390912#5108. Prehistoric ProgramsnocrizWA 3ms4456kbC++14841b2024-04-16 07:35:162024-04-16 07:35:16

Judging History

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

  • [2024-04-16 07:35:16]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4456kb
  • [2024-04-16 07:35:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	int n;
	cin>>n;
	vector<pair<pii, int>> V;
	for(int i=0;i<n;i++) {
		string s;
		cin>>s;
		int su = 0, mi = 0;
		for(auto ct:s) {
			su += (ct == '(')?1 : -1;
			mi = min(mi, su);
		}
		V.push_back(make_pair(make_pair(-mi, su), i+1));
	}
	sort(V.begin(), V.end());
	vector<int> ans;
	int cs = 0;
	for(auto ct: V) {
		if(cs-ct.first.first < 0) {
			cout<<"impossible\n";
			return 0;
		}
		cs += ct.first.second;
		ans.push_back(ct.second);
	}
	for(auto ct: ans) {
		cout<<ct<<'\n';
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 4456kb

input:

50000
(
(
))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()(
)
(
)
(((
(
(
(
(
(
()
(
)
(
)((())()((
)))))(
(
)
))
)()
(
)
)
)()(
(
(
()
(
)
(
)()((((())()))())(
(
(
)(
(
(
(()())())
)
)
(
(
(
)((())))((())))))))))((((()()))()))))))))((()())()))
)
)()
)
)
)
)
)
())(())))))()(()((()(())...

output:

impossible

result:

wrong answer you didn't find a solution but jury did