QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#390912 | #5108. Prehistoric Programs | nocriz | WA | 3ms | 4456kb | C++14 | 841b | 2024-04-16 07:35:16 | 2024-04-16 07:35:16 |
Judging History
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