QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#110336 | #5108. Prehistoric Programs | jyhptr | WA | 6ms | 4296kb | C++20 | 1.6kb | 2023-06-01 16:17:38 | 2023-06-01 16:17:42 |
Judging History
answer
// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#else
#define debug(x...) {};
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define double long double
#define int long long
#define MAXN 200010
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n; cin >> n;
struct node {
int minv, sum, id;
bool operator<(const node &o) const {
return minv > o.minv || (minv == o.minv && sum > o.sum);
};
};
vector<node> f(n);
rep(i, 0, n) {
string s; cin >> s;
int minv = 0, sum = 0;
rep(j, 0, s.length()) {
if (s[j] == '(') sum++;
else sum--;
minv = min(minv, sum);
}
f[i] = {minv, sum, i+1};
}
sort(f.begin(), f.end());
debug(f)
int sum = 0;
rep(i, 0, n) {
if (sum + f[i].minv < 0) {
print("impossible");
return 0;
}
sum += f[i].sum;
}
if (sum != 0) {
print("impossible");
return 0;
}
rep(i, 0, n) {
cout << f[i].id << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 4296kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did