Submission #1311612

#TimeUsernameProblemLanguageResultExecution timeMemory
1311612franuchMonochrome Points (JOI20_monochrome)C++20
Compilation error
0 ms0 KiB
/*====================*\
|                      |
|  written by Franuch  | 
|                      |
\*====================*/



/* \/ *\

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&#&#&&&&&&&&&&&&#####B#####BBBBBB######&&&&&&&&@&&&@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&##&&&&&&&&&&&&&&&&######BBBBBBBB#########&&&&&&&&&@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@&&@@@@@@@@&##&#########BBBGGGGGGGBBBBB##############&&@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@&#BBBBBBBBGGGGGGGGGGGBBBBBBBBBBBB#####&&@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#BGPGGGGGGGGGGGGGGGGGBGBBBBBBB######&&&
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&@@@@@@@@@@@@@#BPPPPPPPPPGGGGGGGGGBBBBBBBBBB#####&&
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&BG5YJ?777?J5G#&@@@@@&&@#GPPPPPPPPPGGGGGGGBBBBBBBBBB#####&&
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&G5J!~^^^^::::::^^~7JPB&@@@@@@@#GPPP5PPPGGGGGGGGGGBBBBBBBBB##&&
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G?~^^::::::::::.....:^^~7?5G#@@@@@&G55P55PPGGGGGGGGGBBBBBBBBB####
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G!.::::::::^^::....  ...:^~!7?JYP#@@@&G55PPPPPGGGGGGGGGBBBBBBBBB###
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@?..:::::::::::.....    ...:^^!7JYYPB&@@@B55PPPPGGGGGGGGGGBBBBBBBB###
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&! .::^^^^:::::............::^~!?YPGB#&@@@@#PPPPPGGGBBBBBBBBBBBBBBB###
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@J.:::^~!!!~~^^^::::...::..::~7?Y5PG#&@@@@@@@#GPGGGGBBBBBBBBBBBBBBBB###
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@B~^^^^~!7!!!~^^:......:!^::^^^~!7?J5G#&&@@@@@@#GGGGBBBBBBBBBBBBBBBBB###
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5~~~~!7!!!!7777!7?7~~.:7:.:^^:^7YPG#&@@@@@@@@@@BGGGGBB####BBBBBBBBB####
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5?7?JJ??Y5GGB#&&@@&##Y??. .~?!J#@@@@@@@@@@@@@@@@BGGGBB#######BBBBBB####
@@@@@@@@@@@@@@@@@@@@@@@@@@@@&5555Y5G&@@@@@@@@@@@@@@#?.  ^YG&@@@@@@@@@@@@@@@@@&GPGGBB######BBBBBB####
@@@@@@@@@@@@@@@@@@@@@@@@@@@@BPGGB#@@@@@@@@@@&&@&@&&B?:..^Y@@@@@@@@@@@@@@@@@@@@BPPGBBBBB####BBBBB####
@@@@@@@@@@@@@@@@@@@@@@@@@@@&GGB&@@@@@@@&##&@&#B#&@#BY~^^7G@@@@@@@@@@@@@@@@@@@@#PPGGBBB#B###BBBBB####
@@@@@@@@@@@@@@@@@@@@@@@@@@@BPG#&@@@@&#BGGB#&@@B5P#&B57^!5&@@@@@@@@@@@@@@@@@@@@&PPGBB######BBBBBB####
@@@@@@@@@@@@@@@@@@@@@@@@@@&PPGB&@@@@&@@@@@@@YG@BYGGP5?~!5@@@@@@@@@@@@@@@@@@@@@&BPGGB######BBBBBBB###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YJJ??JJ77????J5P5YPB##@@@@@@@@@@@@@@@@@@@@@@BGGGBBBBBBB#&&
@@@@@@@@@@@@@@#GBB#@&BGB&@&&@@&&#BGGGPGB#&&BGGGGGGGBBB##&&##@@@@@@@@@@@@@@@@@@@@@@@@@@@#BBBBBBBB##&&
@@@@@@@@@@@@@#?!YGB##BGGG#@@&@@@@@&&&&#&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#BBB####&&@
@@@@@@@@@@@@@G!~~?PGGBBGGPG#@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##&&&&&&@
@@@@@@@@@@@@@@G7~~!YGGGGGGGGB&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@&&&&&&&@#5~^^75GGGBB###&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&@@@@

\* /\ */



//\\//\\//\\//\\//\\//\\//\\//\\//\\// utils and macros //\\//\\//\\//\\//\\//\\//\\//\\//\\//

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef __int128 lll;
#define vc vector
#define st first
#define nd second
#define pll pair<ll, ll>
#define sz(a) (ll)a.size()
#define all(a) a.begin(), a.end()
#define pub push_back
#define pob pop_back

void program();

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	program();
	return 0;
}

ll INF = 1e18;
vc<ll> P9 = {998'244'353, 1'000'000'007, 1'000'000'009, 1'000'000'021, 1'000'000'033, 1'000'000'087, 1'000'000'093};
ll MOD = P9[0];

bool cont(ll mask, ll i) {
	return (mask & (1ll << i)) != 0;
}

ll msb(ll mask) {
	if (mask == 0)
		return -1;
	return 63 - __builtin_clzll(mask);
}

ll ceil(ll a, ll b) {
	return (a + b - 1) / b;
}

ll f(ll x) {
	x %= MOD;
	if (x < 0)
		x += MOD;
	return x;
}

ll fme(ll a, ll b) {
	ll ret = 1, x = a;
	while (b > 0) {
		if (b % 2 == 1)
			ret = f(ret * x);
		x = f(x * x);
		b /= 2;
	}
	return ret;
}

ll inv(ll x) {
	return fme(x, MOD - 2);
}

//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//



//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\// solution //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//

void program() {
	ll n;
	cin >> n;
	vc<ll> a(2 * n);
	string str;
	cin >> str;
	for (ll i = 0; i < 2 * n; i++)
		a[i] = str[i] == 'B';
	auto count = [&]() {
		vc<ll> l, r;
		for (ll i = 0; i < n; i++)
			if (a[i] == 1)
				l.pub(i);
		for (ll i = n; i < 2 * n; i++)
			if (a[i] == 0)
				r.pub(i - n);
		ll x = 0;
		for (ll i = 0; i < sz(l); i++)
			x += abs(r[i] - l[i]);
		return n * (n - 1) / 2 - x;
	};
	ll ans = 0;
	for (ll t = 0; t < min(n, 1000); t++) {
		ans = max(ans, count());
		a.insert(a.begin(), a.back());
		a.pob();
	}
	cout << ans << "\n";
}

Compilation message (stderr)

monochrome.cpp: In function 'void program()':
monochrome.cpp:160:31: error: no matching function for call to 'min(ll&, int)'
  160 |         for (ll t = 0; t < min(n, 1000); t++) {
      |                            ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from monochrome.cpp:66:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
monochrome.cpp:160:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  160 |         for (ll t = 0; t < min(n, 1000); t++) {
      |                            ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
monochrome.cpp:160:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  160 |         for (ll t = 0; t < min(n, 1000); t++) {
      |                            ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
monochrome.cpp:160:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  160 |         for (ll t = 0; t < min(n, 1000); t++) {
      |                            ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
monochrome.cpp:160:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  160 |         for (ll t = 0; t < min(n, 1000); t++) {
      |                            ~~~^~~~~~~~~