Submission #1098958

#TimeUsernameProblemLanguageResultExecution timeMemory
1098958crafticatBoarding Passes (BOI22_passes)C++17
0 / 100
41 ms348 KiB
#include <bits/stdc++.h> #include <utility> using ll = long long; using namespace std; #define F0R(i, n) for (ll i= 0; i < n;i++) template<typename T> using V = vector<T>; using vi = V<ll>; using vvi = V<vi>; #define pb push_back using pi = pair<ll, ll>; #define all(x) begin(x), end(x) #define f first #define s second #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; double add(vi x, Tree<int> &points) { double expected = 0; F0R(i, x.size()) { points.insert(x[i]); } F0R(i, x.size()) { int lef = points.order_of_key(x[i]); int rig = points.size() - lef - 1; expected += min(lef, rig) / 2.0; } return expected; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string str; cin >> str; set<int> ind; vvi groups(26); F0R(i, str.size()) { int id = str[i] - 'A'; groups[id].pb(i); ind.insert(id); } vi perm; for (auto x : ind) perm.pb(x); double ans = 1e9; do { Tree<int> points; double expected = 0; for (auto x : perm) { expected += add(groups[x], points); } ans = min(ans, expected); } while (std::next_permutation(all(perm))); cout << ans; return 0; }

Compilation message (stderr)

passes.cpp: In function 'double add(vi, Tree<int>&)':
passes.cpp:7:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int, std::allocator<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define F0R(i, n) for (ll i= 0; i < n;i++)
......
   27 |     F0R(i, x.size()) {
      |         ~~~~~~~~~~~                
passes.cpp:27:5: note: in expansion of macro 'F0R'
   27 |     F0R(i, x.size()) {
      |     ^~~
passes.cpp:7:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int, std::allocator<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define F0R(i, n) for (ll i= 0; i < n;i++)
......
   30 |     F0R(i, x.size()) {
      |         ~~~~~~~~~~~                
passes.cpp:30:5: note: in expansion of macro 'F0R'
   30 |     F0R(i, x.size()) {
      |     ^~~
passes.cpp: In function 'int main()':
passes.cpp:7:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define F0R(i, n) for (ll i= 0; i < n;i++)
......
   46 |     F0R(i, str.size()) {
      |         ~~~~~~~~~~~~~              
passes.cpp:46:5: note: in expansion of macro 'F0R'
   46 |     F0R(i, str.size()) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...