Submission #53489

#TimeUsernameProblemLanguageResultExecution timeMemory
53489baactreeMatch (CEOI16_match)C++17
10 / 100
2050 ms568 KiB
#include <bits/stdc++.h> using namespace std; int n; char str[100005]; int sum[100005]; bool solve(int le, int ri) { if (le > ri)return true; for (int i = ri; i > le; i--) { if (str[i] == str[le] && solve(le+1,i-1)&&solve(i+1,ri)) { str[i] = ')'; str[le] = '('; return true; } } return false; } int main() { scanf("%s", str + 1); n = strlen(str + 1); for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] ^ (1 << (str[i] - 'a')); if(solve(1, n)) printf("%s\n", str + 1); else printf("-1\n"); return 0; }

Compilation message (stderr)

match.cpp: In function 'int main()':
match.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", str + 1);
  ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...