Submission #997455

#TimeUsernameProblemLanguageResultExecution timeMemory
997455DanielPr8Monochrome Points (JOI20_monochrome)C++14
4 / 100
2067 ms456 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using vvl = vector<vll>; using vb = vector<bool>; using vvb = vector<vb>; using pll = pair<ll,ll>; using vpl = vector<pll>; using vvp = vector<vpl>; #define f first #define s second #define pb push_back #define all(v) v.begin(),v.end() ll n, finale=0; vll b, w; ll di(ll a, ll b){ return min(min(abs(a-b), abs(a-b+n)), abs(a-b-n)); } bool ins(pll a, pll b){ if(a.f>a.s)swap(a.f, a.s); if(b.f>b.s)swap(b.f, b.s); if(a.f>b.f)swap(b, a); return (b.f<a.s && a.s<b.s); } ll solve(vpl& ans){ ll ret = 0; for(ll i = 0; i < n/2; ++i){ for(ll j = i+1; j < n/2; ++j){ if(ins(ans[i], ans[j]))ret++; } } return ret; } void en(vll& per){ vpl nxt; for(ll i = 0; i < n/2; ++i){ nxt.pb({b[i], w[per[i]]}); } finale = max(finale, solve(nxt)); } void alo(ll m, vb& pas, vll& per){ if(m==0)en(per); for(ll i = 0; i < pas.size(); ++i){ if(!pas[i]){ per.pb(i); pas[i]=1; alo(m-1, pas, per); per.pop_back(); pas[i]=0; } } } int main(){ ios_base::sync_with_stdio(0);cin.tie(NULL); string s; cin >> n >> s;n*=2; for(ll i = 0; i < n; ++i){ if(s[i]=='B')b.pb(i); else w.pb(i); } vb pas(n/2); vll per; alo(n/2, pas, per); cout << finale; }

Compilation message (stderr)

monochrome.cpp: In function 'void alo(ll, vb&, vll&)':
monochrome.cpp:44:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(ll i = 0; i < pas.size(); ++i){
      |                   ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...