Submission #785806

#TimeUsernameProblemLanguageResultExecution timeMemory
785806RecursiveCoArt Collections (BOI22_art)C++17
100 / 100
1452 ms660 KiB
// CF template, version 3.0 #include <bits/stdc++.h> #include "art.h" using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} //#define int long long void solve(int n) { vector<int> order; forto(n, i) order.push_back(i + 1); int initial = publish(order); vector<int> actual(n, -1); int prev = initial; forto(n - 1, i) { vector<int> neworder; for (int j = i + 1; j < n; j++) neworder.push_back(j + 1); for (int j = i; j >= 0; j--) neworder.push_back(j + 1); int inv = publish(neworder); int diff = inv - prev; int needed = (diff + n - i - 1) / 2; int below = 0; for (int j = n - 1; j >= 0; j--) { if (below == needed && actual[j] == -1) { actual[j] = i + 1; break; } below += actual[j] == -1; } prev = inv; } forto(n, i) if (actual[i] == -1) actual[i] = n; answer(actual); }

Compilation message (stderr)

art.cpp: In function 'void solve(int)':
art.cpp:16:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
art.cpp:23:5: note: in expansion of macro 'forto'
   23 |     forto(n, i) order.push_back(i + 1);
      |     ^~~~~
art.cpp:16:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
art.cpp:27:5: note: in expansion of macro 'forto'
   27 |     forto(n - 1, i) {
      |     ^~~~~
art.cpp:16:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
art.cpp:44:5: note: in expansion of macro 'forto'
   44 |     forto(n, i) if (actual[i] == -1) actual[i] = n;
      |     ^~~~~
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...