QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89853 | #5108. Prehistoric Programs | _skb_# | WA | 14ms | 6208kb | C++14 | 1.6kb | 2023-03-21 16:55:30 | 2023-03-21 16:55:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector <string> a(n);
vector <pair <pair <int, int>, int>> aa(n);
auto get_p = [&](string &s) {
stack <char> st;
for (int i = 0; i < (int) s.size(); ++i) {
if (st.empty()) st.push(s[i]);
else if (st.top() == '(' and s[i] == ')') st.pop();
else st.push(s[i]);
}
int o = 0, c = 0;
while (!st.empty()) {
if (st.top() == '(') o++;
else c++;
st.pop();
}
return make_pair(o, c);
};
vector <pair <pair <int, int>, int>> ax, ay, axyp, axyn;
for (int i = 0; i < n; ++i) {
cin >> a[i];
aa[i] = {get_p(a[i]), i};
if (aa[i].first.second == 0) ax.push_back(aa[i]);
else if (aa[i].first.first == 0) ay.push_back(aa[i]);
else if (aa[i].first.first - aa[i].first.second <= 0) axyn.push_back(aa[i]);
else if (aa[i].first.first - aa[i].first.second > 0) axyp.push_back(aa[i]);
}
sort(ax.begin(), ax.end());
sort(ay.begin(), ay.end());
sort(axyn.begin(), axyn.end(), [&](auto a, auto b) {
return a.first.second > b.first.second;
});
sort(axyp.begin(), axyp.end(), [&](auto a, auto b) {
return a.first.second < b.first.second;
});
for (auto [p, id] : ax) cout << id + 1 << '\n';
for (auto [p, id] : ay) cout << id + 1 << '\n';
for (auto [p, id] : axyn) cout << id + 1 << '\n';
for (auto [p, id] : axyp) cout << id + 1 << '\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 14ms
memory: 6208kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
13 29 65 69 103 129 133 163 164 172 178 241 307 383 418 506 540 542 586 608 652 687 826 896 919 925 929 969 1021 1031 1060 1093 1141 1170 1334 1491 1677 1689 1753 1767 1911 1946 1978 2004 2087 2135 2170 2216 2238 2321 2380 2420 2472 2540 2551 2560 2665 2724 2735 2743 2768 2812 2892 2933 2937 3064 30...
result:
ok good plan
Test #2:
score: 0
Accepted
time: 4ms
memory: 3508kb
input:
1000 ( ))(())) ((((())())))((())(()))( )( ) ))) ))((()(((((((())()(())()())))(()(())()())))))))((()((()())()())(())))()((()()) )((()()()(())(()))()(())()))(()))))())))))))))))))()))(()()(())(()))())()()))))(())()()()((())(()))(())))))))(()()())()))()())))()()))))))( )))((( ( )))()()()))) ( (((())(((...
output:
30 35 45 84 85 112 115 123 128 197 221 297 397 429 433 489 596 617 626 653 762 788 790 879 962 983 1 3 10 12 14 18 22 54 58 64 65 75 77 89 90 92 97 101 104 106 110 122 125 126 135 136 143 147 162 166 178 179 181 182 188 189 190 198 206 209 212 213 215 216 217 223 228 229 242 243 245 247 252 253 265 ...
result:
ok good plan
Test #3:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
2 () ()
output:
1 2
result:
ok good plan
Test #4:
score: 0
Accepted
time: 0ms
memory: 3344kb
input:
2 (( ))
output:
1 2
result:
ok good plan
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3472kb
input:
2 )( ()
output:
2 1
result:
wrong answer wrong plan (expected impossible)