Submission #516349

#TimeUsernameProblemLanguageResultExecution timeMemory
516349qwerasdfzxclMonochrome Points (JOI20_monochrome)C++14
25 / 100
2065 ms320 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const ll INF = 1e18; char a[400400]; int B[200200], W[200200]; vector<pair<int, int>> E; int calc(){ for (auto &p:E) if (p.first > p.second) swap(p.first, p.second); sort(E.begin(), E.end()); int ret = 0; for (int i=0;i<(int)E.size();i++){ //printf("%d %d\n", E[i].first, E[i].second); for (int j=i+1;j<(int)E.size();j++) if (E[j].first < E[i].second && E[i].second < E[j].second) ret++; } //printf("\n"); return ret; } int main(){ int n; scanf("%d", &n); scanf("%s", a+1); n *= 2; int cb = 0, cw = 0; for (int i=1;i<=n;i++){ if (a[i]=='B') B[++cb] = i; else W[++cw] = i; } int ans = 0; for (int z=1;z<=n/2;z++){ E.clear(); int pt = z; for (int i=1;i<=n/2;i++){ E.emplace_back(B[i], W[pt]); pt++; if (pt>n/2) pt -= n/2; } ans = max(ans, calc()); } printf("%d\n", ans); return 0; }

Compilation message (stderr)

monochrome.cpp: In function 'int main()':
monochrome.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
monochrome.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%s", a+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...