Submission #598847

#TimeUsernameProblemLanguageResultExecution timeMemory
598847MadokaMagicaFanArt Collections (BOI22_art)C++17
100 / 100
1671 ms736 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; #define forn(i,n) for(int i = 0; i < n; ++i) #define forr(i,n) for(int i = n-1; i >= 0; --i) #define forbe(i,b,e) for(int i = b; i < e; ++i) #define all(v) (v).begin(),(v).end() #define sort(v) sort(all(v)) #define sz(v) ((int)(v).size()) #define endl '\n' int publish(vi r); void answer(vi r); void solve (int n) { vi r(n); vi ans(n); int res, lres, fst; forn(i, n) { forn(j, n) { r[(n+j-i)%n] = j+1; } res = publish(r); if (!i) { fst = res; lres = res; continue; } ans[(lres-res+n-1)>>1] = i; lres = res; } res = fst; ans[(lres-res+n-1)>>1] = n; answer(ans); } #ifdef ONPC int rn; vi rs; vi pl; int publish(vi r) { int ret = 0; forbe(i,0,rn) cout << r[i] << ' '; cout << endl; forbe(i,1,rn) { forn(j,i) { if (pl[r[i]-1] < pl[r[j]-1]) ++ret; } } return ret; } void answer(vi r){ forbe(i,0,rn) cout << r[i] << ' '; forn(i, rn) { if (rs[i] != r[i]) { cout << "NO\n"; return; } } cout << "YES\n"; } void rezolvare() { cin >> rn; rs.assign(rn,0); pl.assign(rn,0); forn(i,rn) cin >> rs[i]; forn(i, rn) pl[rs[i]-1] = i; solve(rn); } int32_t main(int argc, char** argv) { if (argc > 1) freopen(argv[1],"r", stdin); rezolvare(); } #endif

Compilation message (stderr)

art.cpp: In function 'void solve(int)':
art.cpp:44:14: warning: 'fst' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     ans[(lres-res+n-1)>>1] = n;
      |          ~~~~^~~~
art.cpp:44:14: warning: 'lres' may be used uninitialized in this function [-Wmaybe-uninitialized]
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...