Submission #521108

# Submission time Handle Problem Language Result Execution time Memory
521108 2022-01-31T18:50:38 Z LucaIlie Mouse (info1cup19_mouse) C++17
36.6667 / 100
158 ms 288 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

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

    if ( n == 1 ) {
        query( { 1 } );
        return;
    }

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

    while ( query( q ) < n && query( q ) > 0 )
        random_shuffle( q.begin(), q.end() );
    if ( query( q ) == n )
        return;

    for ( i = 0; i < n; i++ ) {
        for ( j = i + 1; j < n; j++ ) {
            if ( i != j ) {
                if ( val[i] != -1 && val[j] != -1 )
                    continue;
                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 != j) ? i + 1 : (i + 2 < n ? i + 2 : i - 1));
                    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[j] = q[j];
                    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 );
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 29
2 Correct 1 ms 200 KB Correct! Number of queries: 13
3 Correct 1 ms 200 KB Correct! Number of queries: 22
4 Correct 1 ms 200 KB Correct! Number of queries: 27
5 Correct 1 ms 200 KB Correct! Number of queries: 23
6 Correct 1 ms 200 KB Correct! Number of queries: 44
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 29
2 Correct 1 ms 200 KB Correct! Number of queries: 13
3 Correct 1 ms 200 KB Correct! Number of queries: 22
4 Correct 1 ms 200 KB Correct! Number of queries: 27
5 Correct 1 ms 200 KB Correct! Number of queries: 23
6 Correct 1 ms 200 KB Correct! Number of queries: 44
7 Correct 14 ms 200 KB Correct! Number of queries: 1100
8 Correct 11 ms 200 KB Correct! Number of queries: 1000
9 Correct 10 ms 200 KB Correct! Number of queries: 900
10 Correct 10 ms 200 KB Correct! Number of queries: 1100
11 Correct 8 ms 288 KB Correct! Number of queries: 800
12 Correct 14 ms 200 KB Correct! Number of queries: 1000
13 Correct 11 ms 200 KB Correct! Number of queries: 900
14 Correct 13 ms 200 KB Correct! Number of queries: 1100
15 Correct 12 ms 200 KB Correct! Number of queries: 1100
16 Correct 15 ms 236 KB Correct! Number of queries: 1000
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 29
2 Correct 1 ms 200 KB Correct! Number of queries: 13
3 Correct 1 ms 200 KB Correct! Number of queries: 22
4 Correct 1 ms 200 KB Correct! Number of queries: 27
5 Correct 1 ms 200 KB Correct! Number of queries: 23
6 Correct 1 ms 200 KB Correct! Number of queries: 44
7 Correct 14 ms 200 KB Correct! Number of queries: 1100
8 Correct 11 ms 200 KB Correct! Number of queries: 1000
9 Correct 10 ms 200 KB Correct! Number of queries: 900
10 Correct 10 ms 200 KB Correct! Number of queries: 1100
11 Correct 8 ms 288 KB Correct! Number of queries: 800
12 Correct 14 ms 200 KB Correct! Number of queries: 1000
13 Correct 11 ms 200 KB Correct! Number of queries: 900
14 Correct 13 ms 200 KB Correct! Number of queries: 1100
15 Correct 12 ms 200 KB Correct! Number of queries: 1100
16 Correct 15 ms 236 KB Correct! Number of queries: 1000
17 Runtime error 158 ms 200 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -