Submission #942082

#TimeUsernameProblemLanguageResultExecution timeMemory
9420828pete8Abracadabra (CEOI22_abracadabra)C++17
10 / 100
242 ms19792 KiB
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<unordered_map> #include <queue> #include<cstring> #include<limits.h> #include <cassert> #include <cstdint> #include<cmath> #include<set> #include<algorithm> #include <iomanip> #include<numeric> //gcd(a,b) #include<bitset> using namespace std; #define ll long long #define f first #define endl "\n" #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define vi vector<int> #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-loops") using namespace std; #define int long long #define double long double const int mod=1e9+7,mxn=3e5+5,lg=30,inf=1e16,minf=-1e9; int n,q; struct sub1{ //there should be a time everything stop chaning(endpoint) //the number of shuffle to get there should not exceed n void simulate(vector<int>&g){ int k=(g.size()/2); int c=0,c2=k; vector<int>ans; while(c<k&&c2<g.size()){ if(g[c]<g[c2])ans.pb(g[c++]); else ans.pb(g[c2++]); } while(c<k)ans.pb(g[c++]); while(c2<g.size())ans.pb(g[c2++]); g=ans; } vector<int>brute[1001]; void solve(){ vector<int>v(n); for(int i=0;i<n;i++)cin>>v[i]; for(int k=0;k<=n;k++){ brute[k]=v; simulate(v); } while(q--){ int t,p;cin>>t>>p; t=min(t,n); cout<<brute[t][p-1]<<'\n'; } } }t1; int32_t main(){ fastio cin>>n>>q; if(n<=1000)t1.solve(); } /* observations: lets observe the max element as its independent so when mx is at m a b m c | g e d f the result array has to be a b g e d f m c so everything after max will be fixed and cant move and will be at the end of the array now considering the 2nd max */ /* 10 0 7 5 2 9 10 8 4 3 6 1 6 3 1 5 6 2 3 4 1 2 0 4 1 5 */

Compilation message (stderr)

Main.cpp: In member function 'void sub1::simulate(std::vector<long long int>&)':
Main.cpp:46:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   while(c<k&&c2<g.size()){
      |              ~~^~~~~~~~~
Main.cpp:51:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   while(c2<g.size())ans.pb(g[c2++]);
      |         ~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...