Submission #487442

# Submission time Handle Problem Language Result Execution time Memory
487442 2021-11-15T13:47:35 Z Koosha_mv Swap (BOI16_swap) C++14
0 / 100
12 ms 23756 KB
#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define Add(x,y) x=(x+y)%mod
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=1e6+99;

int n,t,a[N];
vector<int> g[N];

int main(){
	cin>>n;
	f(i,1,n+1){
		cin>>a[i];
	}
	f_(i,n,2){
		g[i/2].pb(i);
	}
	f(i,1,n+1){
		pair<int,int> mn=mp(a[i],-1);
		reverse(g[i].begin(),g[i].end());
		f(j,0,g[i].size()){
			minm(mn,mp(a[g[i][j]],j));
		}
		if(mn.S==-1) continue;
		swap(a[i],a[g[i][mn.S]]);
		f(j,0,mn.S){
			g[g[i][j]].pb(g[i][mn.S]);
		}
	}
	f(i,1,n+1){
		cout<<a[i]<<" ";
	}
}

Compilation message

swap.cpp: In function 'int main()':
swap.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   36 |   f(j,0,g[i].size()){
      |     ~~~~~~~~~~~~~~~            
swap.cpp:36:3: note: in expansion of macro 'f'
   36 |   f(j,0,g[i].size()){
      |   ^
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23756 KB Output isn't correct
2 Halted 0 ms 0 KB -