답안 #315496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315496 2020-10-23T01:29:43 Z daniel920712 Mouse (info1cup19_mouse) C++14
27.4598 / 100
979 ms 756 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include "grader.h"

using namespace std;
vector < int > how;
bool have[500]={0};
void solve(int N)
{
    int a,b,c,now,i,j,k,ok;
    how.clear();
    for(i=0;i<N;i++)
    {
        how.push_back(i+1);
        have[i+1]=0;
    }

    for(i=0;i<N;i++)
    {
        for(j=1;j<=N;j++)
        {
            if(!have[j])
            {
                how[i]=j;
                now=0;
                for(k=1;k<=N;k++)
                {
                    if(!have[k]&&k!=j)
                    {
                        how[i+now+1]=k;
                        now++;
                    }
                }
            }
            a=query(how);
            if(a==N) return;
            if(i==0)
            {
                ok=1;
                for(k=i+1;k<N;k++)
                {
                    swap(how[i],how[k]);
                    b=query(how);
                    if(b==N) return;
                    swap(how[i],how[k]);
                    if(a>b) continue;
                    else
                    {
                        ok=0;
                        break;
                    }
                }
                if(ok)
                {
                    have[how[i]]=1;
                    break;
                }
            }
            else
            {
                swap(how[i],how[0]);
                b=query(how);
                if(b==N) return;

                swap(how[i],how[0]);

                if(a-b==2)
                {
                    have[how[i]]=1;
                    break;
                }
            }
        }
    }
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:12:13: warning: unused variable 'c' [-Wunused-variable]
   12 |     int a,b,c,now,i,j,k,ok;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Correct! Number of queries: 36
2 Correct 1 ms 256 KB Correct! Number of queries: 19
3 Correct 1 ms 256 KB Correct! Number of queries: 43
4 Correct 1 ms 256 KB Correct! Number of queries: 58
5 Correct 1 ms 256 KB Correct! Number of queries: 42
6 Correct 1 ms 256 KB Correct! Number of queries: 52
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Correct! Number of queries: 36
2 Correct 1 ms 256 KB Correct! Number of queries: 19
3 Correct 1 ms 256 KB Correct! Number of queries: 43
4 Correct 1 ms 256 KB Correct! Number of queries: 58
5 Correct 1 ms 256 KB Correct! Number of queries: 42
6 Correct 1 ms 256 KB Correct! Number of queries: 52
7 Correct 30 ms 256 KB Correct! Number of queries: 2400
8 Correct 36 ms 256 KB Correct! Number of queries: 2600
9 Correct 31 ms 256 KB Correct! Number of queries: 2200
10 Correct 44 ms 256 KB Correct! Number of queries: 2600
11 Correct 30 ms 256 KB Correct! Number of queries: 1900
12 Correct 33 ms 256 KB Correct! Number of queries: 2500
13 Correct 30 ms 256 KB Correct! Number of queries: 2200
14 Correct 38 ms 384 KB Correct! Number of queries: 2600
15 Correct 35 ms 256 KB Correct! Number of queries: 2600
16 Correct 35 ms 256 KB Correct! Number of queries: 2600
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Correct! Number of queries: 36
2 Correct 1 ms 256 KB Correct! Number of queries: 19
3 Correct 1 ms 256 KB Correct! Number of queries: 43
4 Correct 1 ms 256 KB Correct! Number of queries: 58
5 Correct 1 ms 256 KB Correct! Number of queries: 42
6 Correct 1 ms 256 KB Correct! Number of queries: 52
7 Correct 30 ms 256 KB Correct! Number of queries: 2400
8 Correct 36 ms 256 KB Correct! Number of queries: 2600
9 Correct 31 ms 256 KB Correct! Number of queries: 2200
10 Correct 44 ms 256 KB Correct! Number of queries: 2600
11 Correct 30 ms 256 KB Correct! Number of queries: 1900
12 Correct 33 ms 256 KB Correct! Number of queries: 2500
13 Correct 30 ms 256 KB Correct! Number of queries: 2200
14 Correct 38 ms 384 KB Correct! Number of queries: 2600
15 Correct 35 ms 256 KB Correct! Number of queries: 2600
16 Correct 35 ms 256 KB Correct! Number of queries: 2600
17 Runtime error 979 ms 756 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Halted 0 ms 0 KB -