Submission #293818

#TimeUsernameProblemLanguageResultExecution timeMemory
293818BTheroMonochrome Points (JOI20_monochrome)C++17
4 / 100
2025 ms384 KiB
// chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAXN = 600 + 5; char s[MAXN]; int n; void solve() { scanf("%d", &n); scanf("%s", s + 1); vector<int> A, B; for (int i = 1; i <= 2 * n; ++i) { if (s[i] == 'B') { A.pb(i); } else { B.pb(i); } } int ans = 0; do { int cur = 0; for (int i = 0; i < n; ++i) { int lc = A[i], rc = B[i]; if (lc > rc) { swap(lc, rc); } for (int j = i + 1; j < n; ++j) { int ln = A[j], rn = B[j]; if (ln > rn) { swap(ln, rn); } if (ln < lc && lc < rn && rn < rc) { ++cur; } else if (lc < ln && ln < rc && rc < rn) { ++cur; } } } ans = max(ans, cur); } while (next_permutation(all(B))); printf("%d\n", ans); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

monochrome.cpp: In function 'void solve()':
monochrome.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
monochrome.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |   scanf("%s", s + 1);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...