Submission #959486

#TimeUsernameProblemLanguageResultExecution timeMemory
959486Bidoneczek11Art Collections (BOI22_art)C++17
100 / 100
1175 ms1604 KiB
#include <bits/stdc++.h>
#include "art.h"
using namespace std;

//#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define nd second
#define st first
#define sz size
#define forr(i, n) for(int i=1;i<=n;i++)
const ll infl=1e18+90;
const int inf=1e9+90;

int X;


int s[8]{0, 7, 4, 5, 2, 1, 3, 6};
/*
void answer(vector<int> a)
{
    for(auto it:a) cout<<it<<" ";
    cout<<"\n";
}

int publish(vector<int> a)
{
    cerr<<"wchodze dla a = ";
    for(auto it:a) cerr<<it<<" ";
    cerr<<"\n";
    int wyn=0;
    for(int i=0;i<X;i++)
    {
        for(int j=i+1;j<X;j++)
        {
            //cerr<<"s["<<i<<"] = "<<s[i]<<" s["<<j<<"] = "<<s[j]<<"\n";
            if(s[a[i]]<s[a[j]])
            {
                //cerr<<"dla i, j = "<<i<<" "<<j<<"\n";
                wyn++;
            }
        }
    }
    cerr<<"zwracam wyn = "<<wyn<<"\n";
    return wyn;
}
*/

vector<int> wek;

void solve(int n)
{
    X=n;
    for(int i=1;i<=n;i++) wek.pb(i);
    int x=publish(wek);
    for(int i=n-2;i>=0;i--)
    {
        for(int j=i;j<n-1;j++) swap(wek[j], wek[j+1]);
        //swap(wek[i], wek[n-1]);
        int x2=publish(wek);
        int r=x2-x;
        x=x2;
        r+=n-1-i;
        r/=2;
        //cerr<<"r = "<<r<<"\n";
        int licz=n-1;
        while(r>0)
        {
            swap(wek[licz], wek[licz-1]);
            licz--;
            r--;
            x--;
        }
        //cerr<<"po i = "<<i<<" wek to ";
        //if(publish(wek)!=x) cerr<<"kurwica\n";
        //cerr<<"\n";
    }
    answer(wek);
}
/*
int main()
{
    solve(7);
}
*/

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