QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89243 | #5108. Prehistoric Programs | HiperEg | WA | 23ms | 4048kb | C++20 | 1.2kb | 2023-03-19 13:21:20 | 2023-03-19 13:21:22 |
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 23ms
memory: 4048kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
Impossible
result:
wrong answer wrong output