Submission #67842

#TimeUsernameProblemLanguageResultExecution timeMemory
67842Goodparentrises (BOI18_parentrises)C++11
0 / 100
3 ms500 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ff first #define ss second #define Maxn 1000009 #define ll long long #define pb push_back #define Inf 1000000009 #define ppb() pop_back() #define pii pair <int , int> #define mid(x, y) (x + y) / 2 #define all(x) x.begin(),x.end() #define llInf 1000000000000000009 #define tr(i, c) for(__typeof(c).begin() i = (c).begin() ; i != (c).end() ; i++) using namespace std; using namespace __gnu_pbds; typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order; int P, T; char s[Maxn]; int main () { //freopen ("file.in", "r", stdin); //freopen ("file.out", "w", stdout); //srand ((unsigned) time ( NULL )); //int randomNumber = rand() % 10 + 1; scanf ("%d%d", &P, &T); if (P == 1) { string s1; vector <pair <int, char> > v; for (int i = 1; i <= T; i++) { scanf ("%s", &s); v.clear (); s1.clear(); s1 = s; int sz = strlen (s); for (int j = 0; j < sz; j++) { if (s[j] == '(') v.pb ({j, '('}); else { if (v.size() > 0 and v.back().ss == '(') s1[v.back().ff] = 'B', s1[j] = 'B', v.ppb (); else v.pb ({j, ')'}); } } for (auto j: v) { if (j.ss == '(') { for (int k = sz - 1; k > j.ff; k--) if (s[k] == ')' and s1[k] == 'B') { s1[k] = 'G', s1[j.ff] = 'R'; break; } } else { for (int k = j.ff - 1; k >= 0; k--) { if (s[k] == '(' and s1[k] == 'B') { s1[k] = 'G', s1[j.ff] = 'R'; break; } } } } bool d = 0; for (int j = 0; j < sz; j++) if (s1[j] == '(' or s1[j] == ')') { d = 1; break; } if (d) puts ("impossible"); else cout << s1 << '\n'; } } return 0; }

Compilation message (stderr)

parentrises.cpp: In function 'int main()':
parentrises.cpp:37:19: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[1000009]' [-Wformat=]
    scanf ("%s", &s);
                 ~~^
parentrises.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%d", &P, &T);
  ~~~~~~^~~~~~~~~~~~~~~~
parentrises.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf ("%s", &s);
    ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...