Submission #937558

#TimeUsernameProblemLanguageResultExecution timeMemory
937558LucaIlieArt Collections (BOI22_art)C++17
70 / 100
1249 ms1672 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; void solve( int n ) { vector<int> p( n ), q( n ), ans( n ); vector<bool> vis( n + 1 ); for ( int i = 0; i < n; i++ ) p[i] = i + 1; int inv = publish( p ); for ( int x = n; x >= 1; x-- ) { q[0] = x; for ( int i = 1; i < x; i++ ) q[i] = i; for ( int i = x; i < n; i++ ) q[i] = i + 1; int dif = publish( q ) - inv; int sum = x - 1; int l = (dif + sum) / 2; for ( int y = 1; y <= n; y++ ) { if ( !vis[y] ) { if ( l == 0 ) { ans[y - 1] = x; vis[y] = true; break; } l--; } } } answer( ans ); }

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...