답안 #775145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775145 2023-07-06T08:14:30 Z vjudge1 Xor Sort (eJOI20_xorsort) C++17
25 / 100
105 ms 12400 KB
// teddybear's code
// the one who loves NBP
// noe the second
// goal: 0 / 8
// get medal in APIO (like TKN)
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

// prob: 
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#define FOR(i,n) for (int i = 0; i<n; i++)
using ll = long long;
using ull = unsigned long long;
ll n,m,t;
ll cnt = 0;
const int maxn = 1e5;
const ll mod = 1e9 + 7;
#define Y "YES"
#define N "NO"
ll a[maxn + 5];
bool visited[1005][1005];
int dist[1005][1005];
int w,h;
int fx[4] = {-1, 1, 0, 0};
int fy[4] = {0, 0, -1, 1};
queue <pair<int,int>> q;

void solve()
{
	cin >> n >> m;
	vector <pair<int,int>> vp;
	for (int i = 1; i<=n; i++)
	{
		cin >> a[i];
	}
	
	int dem = 0;
	while (true)
	{
		dem = 0;
		for (int i = 1; i<=n-1; i++)
		{
			if (a[i] < a[i+1])
			{
				dem++;	
			}	
			else
			{
				swap(a[i], a[i+1]);
				vp.push_back({i, i+1});
				vp.push_back({i+1, i});
				vp.push_back({i, i+1});
			}
		}
		if (dem == n-1)
		{
			break;
		}
		/*cout << "! ";
		for (int i = 1; i<=n; i++)
		{
			cout << a[i] << ' ';
		}
		cout << '\n';*/
	}
	cout << vp.size() << '\n';
	for (auto j : vp)
	{
		cout << j.first << ' ' << j.second << '\n';
	}
}

void init()
{
 	int te = 1; //cin >> te;
 	while (te--)
 	{
 	 	  solve();
 	}
}

void preprocess()
{

}


int main()
{
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL);
    //cin.tie(0); cout.tie(0);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
 	init();
 	preprocess();
 	//solve();
 	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 2 ms 728 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 4 ms 984 KB Output is correct
13 Correct 4 ms 984 KB Output is correct
14 Correct 4 ms 984 KB Output is correct
15 Correct 4 ms 984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 2 ms 728 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 4 ms 984 KB Output is correct
13 Correct 4 ms 984 KB Output is correct
14 Correct 4 ms 984 KB Output is correct
15 Correct 4 ms 984 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 4 ms 872 KB Output is correct
19 Correct 5 ms 856 KB Output is correct
20 Correct 4 ms 856 KB Output is correct
21 Correct 4 ms 856 KB Output is correct
22 Correct 4 ms 856 KB Output is correct
23 Correct 4 ms 856 KB Output is correct
24 Correct 3 ms 856 KB Output is correct
25 Correct 3 ms 856 KB Output is correct
26 Incorrect 7 ms 1236 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 4 ms 900 KB Output is correct
5 Incorrect 105 ms 12400 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -