Submission #258483

# Submission time Handle Problem Language Result Execution time Memory
258483 2020-08-06T04:24:34 Z 반딧불(#5073) Swap (BOI16_swap) C++17
0 / 100
0 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int arr[200002];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
    for(int i=2; i<=n; i+=2){
        if(i==n){
            if(arr[i/2] > arr[i]) swap(arr[i/2], arr[i]);
        }
        else{
            int tmin = min({arr[i/2], arr[i], arr[i+1]});
            if(tmin == arr[i/2]) continue;
            else if(tmin == arr[i]) swap(arr[i/2], arr[i]);
            else{
                if(arr[i] > arr[i/2]) swap(arr[i/2], arr[i]);
                swap(arr[i/2], arr[i+1]);
            }
        }
    }
    for(int i=1; i<=n; i++) printf("%d ", arr[i]);
}

Compilation message

swap.cpp: In function 'int main()':
swap.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
swap.cpp:12:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
                             ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -