Submission #1233640

#TimeUsernameProblemLanguageResultExecution timeMemory
1233640SpyrosAlivArt Collections (BOI22_art)C++20
20 / 100
54 ms408 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; // // --- Sample implementation for the task art --- // // To compile this program with the sample grader, place: // art.h art_sample.cpp sample_grader.cpp // in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory, // left click on "Open in terminal") and enter e.g.: // g++ -std=c++17 art_sample.cpp sample_grader.cpp // in this folder. This will create a file a.out in the current directory which you can execute from the terminal // as ./a.out // See task statement or sample_grader.cpp for the input specification // int n; vector<int> p; bool smaller(int a, int b) { vector<int> perm; perm.push_back(a); perm.push_back(b); for (int i = 1; i <= n; i++) { if (i != a && i != b) perm.push_back(i); } int tot = publish(perm); swap(perm[0], perm[1]); int tot2 = publish(perm); if (tot2 > tot) { return 1; } else return 0; } void merge(int l, int r) { if (l == r) return; int mid = (l + r) / 2; merge(l, mid); merge(mid+1, r); vector<int> a, b; for (int i = l; i <= mid; i++) a.push_back(p[i]); for (int i = mid+1; i <= r; i++) b.push_back(p[i]); vector<int> fin; int pa = 0, pb = 0; while (pa < (int)a.size() && pb < (int)b.size()) { if (smaller(a[pa], b[pb])) { fin.push_back(a[pa]); pa++; } else { fin.push_back(b[pb]); pb++; } } while (pa < (int)a.size()) { fin.push_back(a[pa]); pa++; } while (pb < (int)b.size()) { fin.push_back(b[pb]); pb++; } for (int i = l; i <= r; i++) { p[i] = fin[i - l]; } } void solve(int N) { n = N; for (int i = 1; i <= n; i++) p.push_back(i); sort(p.begin(), p.end(), [&](int a, int b) { return smaller(a, b); }); answer(p); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...