답안 #843674

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
843674 2023-09-04T11:46:37 Z Andrijanikolic73 Xor Sort (eJOI20_xorsort) C++17
25 / 100
978 ms 19156 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++){
        int r=1e18;
        for(int j=i+1;j<=n;j++){
            if(a[i]>a[j]){
                r=min(r,a[j]);
            }
        }
        if(r!=1e18){
            for(int j=i+1;j<=n;j++){
                if(a[j]==r){
                    Swap(i,j);
                    break;
                }
            }
        }
    }
    cout<<V.size();
    cout<<endl;
    for(auto it:V){
        cout<<it.first<<" "<<it.second;
        cout<<endl;
    }
    //for(int i=1;i<=n;i++)cout<<a[i]<<" ";
}
/*
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 0 ms 348 KB Output is correct
3 Correct 2 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 20 ms 984 KB Output is correct
7 Correct 20 ms 984 KB Output is correct
8 Correct 23 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 344 KB Output is correct
12 Correct 40 ms 1492 KB Output is correct
13 Correct 41 ms 1488 KB Output is correct
14 Correct 41 ms 1492 KB Output is correct
15 Correct 47 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 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 20 ms 984 KB Output is correct
7 Correct 20 ms 984 KB Output is correct
8 Correct 23 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 344 KB Output is correct
12 Correct 40 ms 1492 KB Output is correct
13 Correct 41 ms 1488 KB Output is correct
14 Correct 41 ms 1492 KB Output is correct
15 Correct 47 ms 1492 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 21 ms 984 KB Output is correct
18 Correct 37 ms 1224 KB Output is correct
19 Correct 38 ms 1236 KB Output is correct
20 Correct 35 ms 1076 KB Output is correct
21 Correct 35 ms 1168 KB Output is correct
22 Correct 36 ms 1172 KB Output is correct
23 Correct 37 ms 1236 KB Output is correct
24 Correct 35 ms 1044 KB Output is correct
25 Correct 36 ms 1232 KB Output is correct
26 Incorrect 78 ms 1728 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 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 36 ms 1188 KB Output is correct
5 Incorrect 978 ms 19156 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -