QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#116302 | #5108. Prehistoric Programs | thanhs | WA | 10ms | 5772kb | C++20 | 1.5kb | 2023-06-28 14:40:14 | 2023-06-28 14:40:18 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef stack<ll> sll;
typedef queue<ll> qll;
typedef deque<ll> dll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
#define endl '\n'
#define pb push_back
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define BACK(i,a,b) for(int i = a; i >= b; i--)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define bp __builtin_popcountll
#define gcd __gcd
#define bit(i,n) ((n>>i)&1)
#define setmin(x,y) x=min((x),(y))
#define setmax(x,y) x=max((x),(y))
const int MAXN = (1e6)+5;
// const ll SQRT = 4;
const long long inf = 1e18;
const long long MOD = 998244353;
int n,c1,c2,mn[MAXN],cost[MAXN];
pair<pair<int,int>,int> a[MAXN];
string s;
signed main()
{
fastIO
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
cin>>n;
FOR(i,0,n-1) a[i].se=i;
FOR(i,0,n-1) a[i].fi.fi=1e8;
FOR(i,0,n-1)
{
cin>>s;
FOR(j,0,s.size()-1)
{
if(s[j]=='(') c1++;
else c2++;
a[i].fi.se+=(s[j]=='('?1:-1);
a[i].fi.fi=min(a[i].fi.fi,a[i].fi.se);
}
}
if(c1!=c2) {cout<<"impossible"; return 0;}
sort(a,a+n,greater<pair<pair<int,int>,int>>());
int cur=0;
FOR(i,0,n-1)
{
if(cur+a[i].fi.fi<0) {cout<<"impossible"; return 0;}
else cur+=a[i].fi.se;
}
FOR(i,0,n-1) cout<<a[i].se+1<<endl;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 10ms
memory: 5772kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did