Submission #487428

# Submission time Handle Problem Language Result Execution time Memory
487428 2021-11-15T13:21:55 Z Koosha_mv Swap (BOI16_swap) C++14
0 / 100
11 ms 23760 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];
		g[i/2].pb(i);
	}
	f(i,1,n+1){
		pair<int,int> mn=mp(a[i],-1);
		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,1,mn.S+1){
			g[g[i][0]].pb(g[i][j]);
		}
	}
	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++)
......
   33 |   f(j,0,g[i].size()){
      |     ~~~~~~~~~~~~~~~            
swap.cpp:33:3: note: in expansion of macro 'f'
   33 |   f(j,0,g[i].size()){
      |   ^
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 23760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 23760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 23760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 23760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 23760 KB Output isn't correct
2 Halted 0 ms 0 KB -