QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190513 | #3673. Generalized German Quotation | maghrabyJr_# | WA | 1ms | 3880kb | C++20 | 1.9kb | 2023-09-29 01:08:08 | 2023-09-29 01:08:09 |
Judging History
answer
#include "bits/stdc++.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
string s= "";
int n;
const int N = 260;
int dp[N][N];
int solve(int L, int R){
if(L > R) return 1;
int &ret= dp[L][R];
if(ret != -1)
return ret;
ret= 0;
for(int j = L + 1; j <= R; j++){
if(s[L] != s[j]){
ret |= solve(L + 1, j - 1) * solve(j + 1, R);
}
}
return ret;
}
char res[260];
void trace(int L, int R){
if(L > R) return;
for(int j = L + 1; j <= R; j++){
if(s[L] != s[j]){
if(solve(L + 1, j - 1) * solve(j + 1, R)){
res[L]= '[';
res[j]= ']';
trace(L + 1, j - 1);
trace(j + 1, R);
return;
}
}
}
}
int32_t main(){
cin.tie(0);
cin.sync_with_stdio(0);
string t; cin>>t;
if(t.length() % 2){
cout<<"Keine Loesung";
return 0;
}
for(int i = 0; i < t.length(); i+=2){
if(t.substr(i, 2) == "<<"){
s += '<';
}else if(t.substr(i, 2) == ">>"){
s += '>';
}else{
cout<<"Keine Loesung";
return 0;
}
}
::memset(dp, -1, sizeof dp);
if(solve(0, s.length() - 1) == 0){
cout<<"Keine Loesung";
}else{
trace(0, s.length() - 1);
for(char c : res)
cout<<c;
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3880kb
input:
<<>><<<<>>>>
output:
[][[]]
result:
wrong answer Unexpected symbol `