Submission #521096

# Submission time Handle Problem Language Result Execution time Memory
521096 2022-01-31T17:57:35 Z LucaIlie Mouse (info1cup19_mouse) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//#include "grader.h"

using namespace std;

int query( vector <int> q ) {
    int ans, i;

    for ( i = 0; i < q.size(); i++ )
        cout << q[i] << " ";
    cout << "\n";
    ans = 0;
    if ( q[0] == 3 )
        ans++;
    if ( q[1] == 5 )
        ans++;
    if ( q[2] == 2 )
        ans++;
    if ( q[3] == 6 )
        ans++;
    if ( q[4] == 1 )
        ans++;
    if ( q[5] == 4 )
        ans++;
    if ( q[6] == 7 )
        ans++;
    cout << ans << "\n";

    return ans;
}

void solve( int n ) {
    int a, i, j, k;
    vector <int> q, val, poz;

    if ( n == 1 ) {
        query( { 1 } );
        return;
    }
    if ( n == 2 ) {
        if ( query( { 1, 2 } ) == 0 )
            query( { 2, 1 } );
        return;
    }

    for ( i = 1; i <= n; i++ ) {
        q.push_back( i );
        val.push_back( -1 );
        poz.push_back( -1 );
    }

    while ( query( q ) > 0 )
        random_shuffle( q.begin(), q.end() );

    for ( i = 0; i < n; i++ ) {
        if ( val[i] == -1 ) {
            for ( j = 0; j < n; j++ ) {
                if ( i != j ) {
                    swap( q[i], q[j] );
                    a = query( q );
                    if ( a == 2 ) {
                        val[i] = q[i];
                        val[j] = q[j];
                    } else if ( a == 1 ) {
                        k = ((i + 1 < n && i + 1 != j) ? i + 1 : (i + 2 < n && i + 2 != j ? i + 2 : (i - 1 >= 0 && i - 1 != j ? i - 1 : i - 2)));
                        swap( q[i], q[k] );
                        a = query( q );
                        if ( a == 3 ) {
                            val[i] = q[i];
                            val[j] = q[j];
                            val[k] = q[k];
                        } else if ( a == 2 )
                            val[i] = q[i];
                         else if ( a == 1 )
                            val[j] = q[j];
                        else
                            val[i] = q[k];
                        swap( q[i], q[k] );
                    }
                    swap( q[i], q[j] );
                }
            }
        }
    }

    query( val );
}

Compilation message

mouse.cpp: In function 'int query(std::vector<int>)':
mouse.cpp:9:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for ( i = 0; i < q.size(); i++ )
      |                  ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccyFA74v.o: in function `query(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x0): multiple definition of `query(std::vector<int, std::allocator<int> >)'; /tmp/ccvHh1Uv.o:mouse.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status