Submission #1068646

#TimeUsernameProblemLanguageResultExecution timeMemory
1068646lollipopText editor (CEOI24_editor)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define int long long #define pb push_back #define s second #define f first #define pf push_front #define inf 100000000000000000 #define bitebi __builtin_popcountll #define FOR( i , n ) for( int i = 0 ; i < n ; i ++ ) #define YES cout <<"YES\n" #define NO cout << "NO\n" #define debug cout << "Here Fine" << endl ; #define pr pair < int , int > #define fbo find_by_order // returns iterator #define ook order_of_key // returns strictly less numbers than key using namespace std ; //#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") using namespace __gnu_pbds; using namespace __gnu_cxx; template<class T> using ordered_set =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ; const double Pi=acos(-1.0); const double EPS=1E-8; const int mod = 1000000007 ; const int mod1 = 998244353 ; const int N = 2e6 + 10 ; mt19937 R(time(0)); map < int , int > ma , ma1 ; int n , sl , sc , el , ec ; int a[ N ] ; set < int > se ; void solve1(){ int x = a[ 0 ] + 1 ; int ans = abs( sl - el ) ; int tt1 = 0 , tt2 = 0 ; int mn = INT_MAX ; // case 1 - go to it immediately int cur1 = abs( sc - ec ) ; mn = min( mn , cur1 ) ; // case 2 - go to right int cur2 = ( x - sc ) + ec - 1 ; if( el <= sl ) cur2 += 2 ; mn = min( mn , cur2 ) ; // case 3 - left int cur3 = ( sc - 1 ) + ( x - ec ) ; if( el >= sl ) cur3 += 2 ; mn = min( mn , cur3 ) ; // now ans ans = ans + mn ; // case 4 -- outside of ans int ds = ( n - sl ) ; ds = ds + ( n - el ) ; ds = ds + min( ec - 1, ( x - ec ) ) ; ans = min( ans , ds ) ; //cout << ds << endl ; cout << ans ; return ; } void solve(){ cin >> n >> sl >> sc >> el >> ec ; FOR( i , n ){ cin >> a[ i ] ; if( i != n - 1 ) se.insert( a[ i ] ) ; } if( se.size() == 1 ){ solve1() ; return ; } } signed main() { ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int t = 1 ; // cin >> t ; while( t -- ){ solve() ; } }

Compilation message (stderr)

Main.cpp: In function 'void solve1()':
Main.cpp:41:6: warning: unused variable 'tt1' [-Wunused-variable]
   41 |  int tt1 = 0 , tt2 = 0 ;
      |      ^~~
Main.cpp:41:16: warning: unused variable 'tt2' [-Wunused-variable]
   41 |  int tt1 = 0 , tt2 = 0 ;
      |                ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...