Submission #1120661

#TimeUsernameProblemLanguageResultExecution timeMemory
1120661vjudge1Art Collections (BOI22_art)C++17
5 / 100
77 ms512 KiB
#include<bits/stdc++.h> #include "art.h" using namespace std; int u[4001]; int p[4001]; int pp[4001]; int nn; //int a[4001]; // int publish(vector<int>r){ // int j=0; // for(int i=0;i<nn;i++){ // //cout<<r[i]<<" "; // if(p[r[i]]<i){ // j+=i-p[r[i]]; // } // } // //cout<<" "<<j; // //cout<<"\n"; // return j; // } // void answer(vector<int>r){ // for(int i=0;i<nn;i++){ // cout<<r[i]<<" "; // } // cout<<"\n"; // } vector<int> get(vector<int>v,int uu,int d,int p){ vector<int>ans; //cout<<uu<<" "<<d<<" "<<p<<"\n"; for(int i=0;i<nn;i++){ if(i==uu){ continue; } if(i==p){ ans.push_back(d); } ans.push_back(v[i]); } return ans; } void solve (int n){ nn=n; vector<int>v; for(int i=1;i<=n;i++){ v.push_back(i); } int k=publish(v); if(k==0){ answer(v); return; } while(publish(v)!=0){ for(int i=0;i<=n;i++){ u[i]=0; } for(int i=n-1;i>=0;i--){ //cout<<"\n\n"; if(u[i]==0){ //cout<<v[i]<<"\n\n"; k=publish(v); if(k==0){ answer(v); return; } int x; int j=i; for(int l=j-1;l>=0;l--){ if(u[l]==0){ vector<int>s=get(v,j,v[j],l); x=publish(s); if(x==0){ answer(s); return; } if(x<k){ k=x; j=l; v=s; } } } //cout<<j<<"\n\n"; u[j]=1; i++; } } } // for(int i=0;i<n;i++){ // cout<<u[i]<<" "; // } // cout<<"\n"; answer(v); } // int main(){ // cin>>nn; // for(int i=0;i<nn;i++){ // cin>>a[i]; // p[a[i]]=i; // } // solve(nn); // }

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