Submission #1093447

#TimeUsernameProblemLanguageResultExecution timeMemory
1093447andrewpArt Collections (BOI22_art)C++17
0 / 100
1 ms344 KiB
//Dedicated to my love, ivaziva #pragma GCC optimize("Ofast") #include "art.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = int64_t; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define dbg(x) cerr << #x << ": " << x << '\n'; const int N = 4010; vector<int> inv[N]; int out[N]; void solve(int n) { vector<int> p; for (int i = 1; i <= n; i++) { inv[i].clear(); out[i] = 0; p.push_back(i); } int ret_st, ret_new; ret_st = publish(p); ret_st = 1; if (ret_st == 0) { answer(p); return; } for (int i = 0; i < n - 1; i++) { swap(p[i], p[i + 1]); ret_new = publish(p); if (ret_new < ret_st) { out[p[i + 1]]++; inv[p[i]].push_back(p[i + 1]); } else { out[p[i]]++; inv[p[i + 1]].push_back(p[i]); } swap(p[i], p[i + 1]); } vector<int> topo; set<pii> st; for (int i = 1; i <= n; i++) { st.insert({out[i], i}); } vector<int> ans; while (!st.empty()) { pii z = *st.begin(); int x = z.second; ans.push_back(x); st.erase(st.begin()); for (int u : inv[x]) { st.erase({out[u], u}); out[u]--; st.insert({out[u], u}); } } answer(ans); } // int32_t main() { // ios::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(nullptr); cerr.tie(nullptr); // return 0; // }

Compilation message (stderr)

interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
#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...