QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190512#3673. Generalized German QuotationmaghrabyJr_#WA 1ms3752kbC++202.0kb2023-09-29 01:00:232023-09-29 01:00:24

Judging History

你现在查看的是最新测评结果

  • [2023-09-29 01:00:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3752kb
  • [2023-09-29 01:00:23]
  • 提交

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\n";
                  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\n";
                           return 0;
                  }
         }
         ::memset(dp, -1, sizeof dp);
         if(solve(0, s.length() - 1) == 0){
                  cout<<"Keine Loesung\n";
         }else{
                  trace(0, s.length() - 1);
                  for(char c : res)
                           cout<<c;
                  cout<<"\n";
         }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3752kb

input:

<<>><<<<>>>>

output:

[][[]]

result:

wrong answer Unexpected symbol `