QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89244 | #5108. Prehistoric Programs | HiperEg | WA | 18ms | 3968kb | C++20 | 1.2kb | 2023-03-19 13:21:59 | 2023-03-19 13:22:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<pair<pair<int, int>, int>> v;
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
string s;
cin >> s;
int balance = 0, menor = 1;
for (auto ch : s)
{
if (ch == ')')
{
balance--;
if (balance < menor)
{
menor = balance;
}
}
else
{
balance++;
}
}
v.push_back({{-menor, -balance}, i});
}
sort(v.begin(), v.end());
//for (auto& s : v) cout << s.first.first << " " << s.first.second << " " << s.second << '\n';
int balanco = 0;
bool poss = true;
for (auto& s : v)
{
int m, b;
tie(m, b) = s.first;
m = -m;
b = -b;
if (balanco+m < 0 or balanco+b < 0) { poss = false; break; }
balanco+=b;
}
if (!poss or balanco != 0) cout << "Impossible\n";
else
{
for (auto& s : v)
{
int c = s.second;
cout << c << '\n';
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 18ms
memory: 3968kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
Impossible
result:
wrong answer wrong output