답안 #690826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
690826 2023-01-30T12:40:25 Z alexdd Mouse (info1cup19_mouse) C++17
48 / 100
163 ms 292 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
int n;
vector<int> p;
bool done[3000];
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;
    int cntdone=0;
    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;
                cntdone+=2;
                cur=aux;
                break;
            }
            else if(aux==cur+1)
            {
                int ava=j;
                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;
                    cntdone++;
                    cur=aux;
                    break;
                }
                else if(cv==aux+2)
                {
                    done[i]=1;
                    done[j]=1;
                    done[ava]=1;
                    cur=cv;
                    cntdone+=3;
                    break;
                }
                else if(cv==aux+1)
                {
                    swap(p[j],p[ava]);
                    done[i]=1;
                    cntdone++;
                    cur=aux;
                    break;
                }
                else
                {
                    swap(p[j],p[ava]);
                    done[j]=1;
                    cntdone++;
                    cur=aux;
                }
            }
        }
    }
    int x;
    if(done[n-1])
    {
        x=query(p);
        return;
    }
    swap(p[n-2],p[n-1]);
    x=query(p);
    return;
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:105:9: warning: variable 'x' set but not used [-Wunused-but-set-variable]
  105 |     int x;
      |         ^
# 결과 실행 시간 메모리 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 1 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
# 결과 실행 시간 메모리 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 1 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 9 ms 208 KB Correct! Number of queries: 500
9 Correct 4 ms 208 KB Correct! Number of queries: 400
10 Correct 8 ms 208 KB Correct! Number of queries: 500
11 Correct 6 ms 208 KB Correct! Number of queries: 400
12 Correct 7 ms 208 KB Correct! Number of queries: 400
13 Correct 6 ms 208 KB Correct! Number of queries: 400
14 Correct 5 ms 208 KB Correct! Number of queries: 500
15 Correct 6 ms 208 KB Correct! Number of queries: 500
16 Correct 6 ms 208 KB Correct! Number of queries: 500
# 결과 실행 시간 메모리 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 1 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 9 ms 208 KB Correct! Number of queries: 500
9 Correct 4 ms 208 KB Correct! Number of queries: 400
10 Correct 8 ms 208 KB Correct! Number of queries: 500
11 Correct 6 ms 208 KB Correct! Number of queries: 400
12 Correct 7 ms 208 KB Correct! Number of queries: 400
13 Correct 6 ms 208 KB Correct! Number of queries: 400
14 Correct 5 ms 208 KB Correct! Number of queries: 500
15 Correct 6 ms 208 KB Correct! Number of queries: 500
16 Correct 6 ms 208 KB Correct! Number of queries: 500
17 Runtime error 163 ms 292 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -