답안 #843658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
843658 2023-09-04T11:07:27 Z Andrijanikolic73 Xor Sort (eJOI20_xorsort) C++17
25 / 100
928 ms 18736 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1001;
int n;
int s;
vector<pair<int,int>>v;
int a[N];
vector<pair<int,int>>V;
void zameni(int i,int j){
    v.push_back({i,j});
    v.push_back({j,i});
    v.push_back({i,j});
    for(auto it:v)a[it.first]^=a[it.second];
    for(auto it:v)V.push_back({it.first,it.second});
    v.clear();
}
void Swap(int i,int j){
    while(j>i){
        zameni(j-1,j);
        j--;
    }
}
signed main(){
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>a[i];
    // kako da zamenim dva suseda ???
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i]>a[j]){
                Swap(i,j);
            }
        }
    }
    cout<<V.size();
    cout<<endl;
    for(auto it:V)cout<<it.first<<" "<<it.second<<endl;
}
/*
5 1
3 2 8 4 1
*/
/*
max 40000 operacija
s=1 a[i]<a[i+1]
s=2 a[i]<=a[i+1]
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 18 ms 728 KB Output is correct
5 Correct 21 ms 984 KB Output is correct
6 Correct 22 ms 984 KB Output is correct
7 Correct 20 ms 984 KB Output is correct
8 Correct 20 ms 984 KB Output is correct
9 Correct 22 ms 984 KB Output is correct
10 Correct 24 ms 984 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 40 ms 1492 KB Output is correct
13 Correct 39 ms 1492 KB Output is correct
14 Correct 45 ms 1492 KB Output is correct
15 Correct 40 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 18 ms 728 KB Output is correct
5 Correct 21 ms 984 KB Output is correct
6 Correct 22 ms 984 KB Output is correct
7 Correct 20 ms 984 KB Output is correct
8 Correct 20 ms 984 KB Output is correct
9 Correct 22 ms 984 KB Output is correct
10 Correct 24 ms 984 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 40 ms 1492 KB Output is correct
13 Correct 39 ms 1492 KB Output is correct
14 Correct 45 ms 1492 KB Output is correct
15 Correct 40 ms 1492 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 22 ms 984 KB Output is correct
18 Correct 37 ms 1208 KB Output is correct
19 Correct 45 ms 1228 KB Output is correct
20 Correct 35 ms 984 KB Output is correct
21 Correct 36 ms 1172 KB Output is correct
22 Correct 36 ms 1220 KB Output is correct
23 Correct 38 ms 1176 KB Output is correct
24 Correct 35 ms 984 KB Output is correct
25 Correct 35 ms 984 KB Output is correct
26 Incorrect 78 ms 1880 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 37 ms 1228 KB Output is correct
5 Incorrect 928 ms 18736 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -