QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#555817 | #5108. Prehistoric Programs | evirir | WA | 13ms | 6428kb | C++20 | 1.3kb | 2024-09-10 10:25:47 | 2024-09-10 10:25:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
using ll = long long;
using ii = pair<ll, ll>;
using ld = long double;
struct St
{
string s;
int id;
int net;
int mn;
auto operator<=>(const St& o) const
{
return tie(mn, net) <=> tie(o.mn, o.net);
}
};
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n; cin>>n;
St a[n];
forn(i,0,n)
{
string s; cin>>s;
int sum = 0;
int mn = 0;
for (const auto c : s)
{
if (c == '(') sum++;
else sum--;
mn = min(mn, sum);
}
a[i] = {s, i, sum, mn};
}
sort(a, a + n, greater<>());
int sum = 0;
forn(i,0,n)
{
for (const auto x : a[i].s)
{
if (x == '(') sum++;
else sum--;
}
if (sum < 0)
{
cout<<"impossible\n";
return 0;
}
}
if (sum != 0)
{
cout<<"impossible\n";
return 0;
}
forn(i, 0, n) cout << a[i].id + 1 << '\n';
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 13ms
memory: 6428kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did