답안 #942082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942082 2024-03-10T08:29:53 Z 8pete8 Abracadabra (CEOI22_abracadabra) C++17
10 / 100
242 ms 19792 KB
#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

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++]);
      |         ~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 242 ms 19792 KB Output is correct
2 Correct 182 ms 19536 KB Output is correct
3 Correct 187 ms 18848 KB Output is correct
4 Correct 157 ms 17716 KB Output is correct
5 Correct 175 ms 19100 KB Output is correct
6 Correct 162 ms 17744 KB Output is correct
7 Correct 194 ms 19312 KB Output is correct
8 Correct 167 ms 17728 KB Output is correct
9 Correct 184 ms 18096 KB Output is correct
10 Correct 185 ms 17680 KB Output is correct
11 Correct 190 ms 18296 KB Output is correct
12 Correct 163 ms 16960 KB Output is correct
13 Correct 182 ms 17508 KB Output is correct
14 Correct 187 ms 18648 KB Output is correct
15 Correct 173 ms 18096 KB Output is correct
16 Correct 8 ms 8156 KB Output is correct
17 Correct 160 ms 17060 KB Output is correct
18 Correct 165 ms 16880 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 242 ms 19792 KB Output is correct
2 Correct 182 ms 19536 KB Output is correct
3 Correct 187 ms 18848 KB Output is correct
4 Correct 157 ms 17716 KB Output is correct
5 Correct 175 ms 19100 KB Output is correct
6 Correct 162 ms 17744 KB Output is correct
7 Correct 194 ms 19312 KB Output is correct
8 Correct 167 ms 17728 KB Output is correct
9 Correct 184 ms 18096 KB Output is correct
10 Correct 185 ms 17680 KB Output is correct
11 Correct 190 ms 18296 KB Output is correct
12 Correct 163 ms 16960 KB Output is correct
13 Correct 182 ms 17508 KB Output is correct
14 Correct 187 ms 18648 KB Output is correct
15 Correct 173 ms 18096 KB Output is correct
16 Correct 8 ms 8156 KB Output is correct
17 Correct 160 ms 17060 KB Output is correct
18 Correct 165 ms 16880 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 484 KB Output is correct
21 Incorrect 1 ms 492 KB Output isn't correct
22 Halted 0 ms 0 KB -