Submission #56185

# Submission time Handle Problem Language Result Execution time Memory
56185 2018-07-10T07:52:03 Z 강태규(#1579) Swap (BOI16_swap) C++11
10 / 100
277 ms 45720 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
int x[200001];
int arr[1 << 19][22];
int main() {
    scanf("%d", &n);
    if (n > 20) return 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", x + i);
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < (1 << (n - 1)); ++j) {
            arr[j][i] = x[i];
        }
    }
    
    for (int i = 2; i <= n; ++i) {
        for (int j = 0; j < (1 << (n - 1)); ++j) {
            if ((j >> (i - 2)) & 1) continue;
            swap(arr[j][i >> 1], arr[j][i]);
        }
    }
    
    int m = 0;
    for (int i = 1; i < (1 << (n - 1)); ++i) {
        for (int j = 1; j <= n; ++j) {
            if (arr[m][j] == arr[i][j]) continue;
            if (arr[i][j] < arr[m][j]) m = i;
            break;
        }
    }
    for (int i = 1; i <= n; ++i) {
        printf("%d ", arr[m][i]);
    }
    
	return 0;
}

Compilation message

swap.cpp: In function 'int main()':
swap.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
swap.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", x + i);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 277 ms 45560 KB Output is correct
2 Correct 261 ms 45560 KB Output is correct
3 Correct 266 ms 45720 KB Output is correct
4 Correct 266 ms 45720 KB Output is correct
5 Correct 264 ms 45720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 45560 KB Output is correct
2 Correct 261 ms 45560 KB Output is correct
3 Correct 266 ms 45720 KB Output is correct
4 Correct 266 ms 45720 KB Output is correct
5 Correct 264 ms 45720 KB Output is correct
6 Incorrect 2 ms 45720 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 277 ms 45560 KB Output is correct
2 Correct 261 ms 45560 KB Output is correct
3 Correct 266 ms 45720 KB Output is correct
4 Correct 266 ms 45720 KB Output is correct
5 Correct 264 ms 45720 KB Output is correct
6 Incorrect 2 ms 45720 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 277 ms 45560 KB Output is correct
2 Correct 261 ms 45560 KB Output is correct
3 Correct 266 ms 45720 KB Output is correct
4 Correct 266 ms 45720 KB Output is correct
5 Correct 264 ms 45720 KB Output is correct
6 Incorrect 2 ms 45720 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 277 ms 45560 KB Output is correct
2 Correct 261 ms 45560 KB Output is correct
3 Correct 266 ms 45720 KB Output is correct
4 Correct 266 ms 45720 KB Output is correct
5 Correct 264 ms 45720 KB Output is correct
6 Incorrect 2 ms 45720 KB Output isn't correct
7 Halted 0 ms 0 KB -