답안 #487438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487438 2021-11-15T13:34:08 Z Koosha_mv Swap (BOI16_swap) C++14
0 / 100
12 ms 23788 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);
		sort(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++)
......
   34 |   f(j,0,g[i].size()){
      |     ~~~~~~~~~~~~~~~            
swap.cpp:34:3: note: in expansion of macro 'f'
   34 |   f(j,0,g[i].size()){
      |   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23756 KB Output is correct
2 Correct 11 ms 23756 KB Output is correct
3 Incorrect 12 ms 23788 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23756 KB Output is correct
2 Correct 11 ms 23756 KB Output is correct
3 Incorrect 12 ms 23788 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23756 KB Output is correct
2 Correct 11 ms 23756 KB Output is correct
3 Incorrect 12 ms 23788 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23756 KB Output is correct
2 Correct 11 ms 23756 KB Output is correct
3 Incorrect 12 ms 23788 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23756 KB Output is correct
2 Correct 11 ms 23756 KB Output is correct
3 Incorrect 12 ms 23788 KB Output isn't correct
4 Halted 0 ms 0 KB -