Submission #813789

# Submission time Handle Problem Language Result Execution time Memory
813789 2023-08-08T03:47:50 Z vjudge1 Monochrome Points (JOI20_monochrome) C++17
25 / 100
2000 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
  #include "/home/trucmai/.vim/tools.h"
  #define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
  #else
  #define debug(x...)
#endif

void open(){
  if(fopen("i.inp","r")){
    freopen("i.inp","r",stdin);
    freopen("o.out","w",stdout);
  }
}

#define ll long long
#define all(a) (a).begin(), (a).end()
#define vi vector<ll>
#define pi pair<ll,ll>
#define pii pair<ll,pair<ll,ll>>
#define fi first
#define se second
#define gcd __gcd
#define mset(a,v) memset(a, v, sizeof(a))
#define endl '\n'
#define spc " "

const int MN = 1e6 + 5,LOG = 27;
const ll MOD = 1e9 + 7,INF = 1e9;
ll n; string s;
vector<ll>b,w;
bool cross(ll x1,ll y1,ll x2,ll y2){
    if(x1 > y1) swap(x1, y1);
    if(x2 > y2) swap(x2, y2);
    if(x1 < x2 && y2 < y1) return false;
    if(x2 < x1 && y1 < y2) return false;
    if(x1 > y2 || x2 > y1) return false;
    return true;
} 
void solve(){
  cin>>n>>s; 
  for(ll i = 0;i < 2*n;++i){ 
    if(s[i] == 'B') b.push_back(i); 
    else w.push_back(i);
  }
  sort(all(b)); sort(all(w));
  //sub 2: best strats: w[i] -> b[i+k]
  ll res = 0;
  for(ll k = 0;k < n;++k){ 
    ll cnt = 0; 
    for(ll i = 0;i < n;++i)
      for(ll j = i+1;j < n;++j)
        if(cross(w[i],b[(i+k)%n],w[j],b[(j+k)%n])) ++cnt;
    res = max(res,cnt);
  }
  cout<<res<<endl;
}

signed main(){
  cin.tie(0) -> sync_with_stdio(0);
  open();
  ll t = 1; //cin>>t;
  while(t--) solve(); 
  
  #ifdef LOCAL
    cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}

Compilation message

monochrome.cpp: In function 'void open()':
monochrome.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("i.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
monochrome.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("o.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 60 ms 212 KB Output is correct
15 Correct 59 ms 320 KB Output is correct
16 Correct 57 ms 316 KB Output is correct
17 Correct 56 ms 316 KB Output is correct
18 Correct 41 ms 312 KB Output is correct
19 Correct 47 ms 316 KB Output is correct
20 Correct 46 ms 212 KB Output is correct
21 Correct 41 ms 312 KB Output is correct
22 Correct 42 ms 320 KB Output is correct
23 Correct 17 ms 212 KB Output is correct
24 Correct 40 ms 316 KB Output is correct
25 Correct 36 ms 308 KB Output is correct
26 Correct 43 ms 312 KB Output is correct
27 Correct 48 ms 312 KB Output is correct
28 Correct 56 ms 308 KB Output is correct
29 Correct 40 ms 312 KB Output is correct
30 Correct 42 ms 212 KB Output is correct
31 Correct 59 ms 308 KB Output is correct
32 Correct 59 ms 212 KB Output is correct
33 Correct 60 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 60 ms 212 KB Output is correct
15 Correct 59 ms 320 KB Output is correct
16 Correct 57 ms 316 KB Output is correct
17 Correct 56 ms 316 KB Output is correct
18 Correct 41 ms 312 KB Output is correct
19 Correct 47 ms 316 KB Output is correct
20 Correct 46 ms 212 KB Output is correct
21 Correct 41 ms 312 KB Output is correct
22 Correct 42 ms 320 KB Output is correct
23 Correct 17 ms 212 KB Output is correct
24 Correct 40 ms 316 KB Output is correct
25 Correct 36 ms 308 KB Output is correct
26 Correct 43 ms 312 KB Output is correct
27 Correct 48 ms 312 KB Output is correct
28 Correct 56 ms 308 KB Output is correct
29 Correct 40 ms 312 KB Output is correct
30 Correct 42 ms 212 KB Output is correct
31 Correct 59 ms 308 KB Output is correct
32 Correct 59 ms 212 KB Output is correct
33 Correct 60 ms 316 KB Output is correct
34 Execution timed out 2043 ms 340 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 60 ms 212 KB Output is correct
15 Correct 59 ms 320 KB Output is correct
16 Correct 57 ms 316 KB Output is correct
17 Correct 56 ms 316 KB Output is correct
18 Correct 41 ms 312 KB Output is correct
19 Correct 47 ms 316 KB Output is correct
20 Correct 46 ms 212 KB Output is correct
21 Correct 41 ms 312 KB Output is correct
22 Correct 42 ms 320 KB Output is correct
23 Correct 17 ms 212 KB Output is correct
24 Correct 40 ms 316 KB Output is correct
25 Correct 36 ms 308 KB Output is correct
26 Correct 43 ms 312 KB Output is correct
27 Correct 48 ms 312 KB Output is correct
28 Correct 56 ms 308 KB Output is correct
29 Correct 40 ms 312 KB Output is correct
30 Correct 42 ms 212 KB Output is correct
31 Correct 59 ms 308 KB Output is correct
32 Correct 59 ms 212 KB Output is correct
33 Correct 60 ms 316 KB Output is correct
34 Execution timed out 2043 ms 340 KB Time limit exceeded
35 Halted 0 ms 0 KB -