Submission #1136262

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11362622025-01-15 12:25:39byunjaewooSwap (BOI16_swap)C++20
100 / 100
570 ms232616 KiB
#include <bits/stdc++.h>
using namespace std;
int a[200002];
bool needed[200002][18][2];
vector<int> dp[200002][18][2], tmp1, tmp2;
void merge(vector<int> &ret, vector<int> &l, vector<int> &r) {
for (int i = 0, j = 1; i < l.size(); i += j, j <<= 1) {
for (int k = i; k < i + j && k < l.size(); k++) ret.push_back(l[k]);
for (int k = i; k < i + j && k < r.size(); k++) ret.push_back(r[k]);
}
}
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
needed[1][0][1] = 1;
for (int node = 1; node <= n / 2; node++) {
for (int i = 0; node >> i; i++)
for (int j : {0, 1}) {
if (!needed[node][i][j]) continue;
int mn =
min({a[((node >> i + 1) << 1) + j], a[2 * node], a[2 * node + 1]});
if (mn == a[((node >> i + 1) << 1) + j]) {
needed[2 * node][0][0] = needed[2 * node + 1][0][1] = 1;
} else if (mn == a[2 * node]) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

swap.cpp: In function 'int main()':
swap.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
swap.cpp:18:43: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         for (int i = 1; i <= n; i++) scanf("%d", a + i);
      |                                      ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...