Submission #690678

# Submission time Handle Problem Language Result Execution time Memory
690678 2023-01-30T10:53:45 Z alexdd Mouse (info1cup19_mouse) C++17
48 / 100
155 ms 280 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
int n;
vector<int> p;
bool done[300];
void solve(int N)
{
    ///reseteaza chestii
    n=N;
    p.clear();
    for(int i=1;i<=n;i++)
    {
        done[i-1]=0;
        done[i]=0;
        p.push_back(i);
    }
    if(n<=2)
    {
        if(query(p)==n)
            return;
        swap(p[0],p[1]);
        if(query(p)==n)
            return;
    }
    while(1)
    {
        int x=query(p);
        if(x==n)
            return;
        if(x==0)
            break;
        random_shuffle(p.begin(),p.end());
    }
    int cur=0,aux;
    for(int i=0;i<n-2;i++)
    {
        if(done[i])
            continue;
        for(int j=i+1;j<n;j++)
        {
            if(done[j])
                continue;
            ///verific daca p[j] ar trebui sa fie pe pozitia i
            swap(p[j],p[i]);
            aux=query(p);
            if(aux==n)
                return;
            if(aux==cur)///nu ii bine
                continue;
            else if(aux==cur+2)
            {
                done[i]=1;
                done[j]=1;
                cur=aux;
                break;
            }
            else if(aux==cur+1)
            {
                int ava=-1;
                for(int u=i+1;u<n;u++)
                    if(u!=j && !done[u])
                        ava=u;
                swap(p[j],p[ava]);
                int cv=query(p);
                if(cv==n)
                    return;
                if(cv>=aux)
                {
                    swap(p[j],p[ava]);
                    done[i]=1;
                    cur=aux;
                    break;
                }
                else
                {
                    swap(p[j],p[ava]);
                    done[j]=1;
                    cur=aux;
                }
            }
        }
    }
    int x=query(p);
    if(x==n)
        return;
    swap(p[n-2],p[n-1]);
    x=query(p);
    if(x==n)
        return;
    while(query(p)<n)
        random_shuffle(p.begin(),p.end());
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct! Number of queries: 14
2 Correct 1 ms 208 KB Correct! Number of queries: 4
3 Correct 0 ms 208 KB Correct! Number of queries: 11
4 Correct 1 ms 208 KB Correct! Number of queries: 11
5 Correct 1 ms 208 KB Correct! Number of queries: 18
6 Correct 1 ms 208 KB Correct! Number of queries: 22
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct! Number of queries: 14
2 Correct 1 ms 208 KB Correct! Number of queries: 4
3 Correct 0 ms 208 KB Correct! Number of queries: 11
4 Correct 1 ms 208 KB Correct! Number of queries: 11
5 Correct 1 ms 208 KB Correct! Number of queries: 18
6 Correct 1 ms 208 KB Correct! Number of queries: 22
7 Correct 6 ms 208 KB Correct! Number of queries: 500
8 Correct 6 ms 208 KB Correct! Number of queries: 500
9 Correct 4 ms 208 KB Correct! Number of queries: 400
10 Correct 6 ms 208 KB Correct! Number of queries: 500
11 Correct 4 ms 208 KB Correct! Number of queries: 400
12 Correct 4 ms 208 KB Correct! Number of queries: 500
13 Correct 6 ms 208 KB Correct! Number of queries: 400
14 Correct 7 ms 208 KB Correct! Number of queries: 500
15 Correct 7 ms 208 KB Correct! Number of queries: 500
16 Correct 7 ms 208 KB Correct! Number of queries: 500
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct! Number of queries: 14
2 Correct 1 ms 208 KB Correct! Number of queries: 4
3 Correct 0 ms 208 KB Correct! Number of queries: 11
4 Correct 1 ms 208 KB Correct! Number of queries: 11
5 Correct 1 ms 208 KB Correct! Number of queries: 18
6 Correct 1 ms 208 KB Correct! Number of queries: 22
7 Correct 6 ms 208 KB Correct! Number of queries: 500
8 Correct 6 ms 208 KB Correct! Number of queries: 500
9 Correct 4 ms 208 KB Correct! Number of queries: 400
10 Correct 6 ms 208 KB Correct! Number of queries: 500
11 Correct 4 ms 208 KB Correct! Number of queries: 400
12 Correct 4 ms 208 KB Correct! Number of queries: 500
13 Correct 6 ms 208 KB Correct! Number of queries: 400
14 Correct 7 ms 208 KB Correct! Number of queries: 500
15 Correct 7 ms 208 KB Correct! Number of queries: 500
16 Correct 7 ms 208 KB Correct! Number of queries: 500
17 Runtime error 155 ms 280 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -