답안 #315499

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

using namespace std;
vector < int > how;
bool have[500]={0};
int xx[500];
map < vector < int > , int > all;
int Query(vector < int > tt)
{
    if(all.find(tt)==all.end()) all[tt]=query(tt);
    return all[tt];
}
void solve(int N)
{
    int a,b,c,now,i,j,jj,kk,k,ok;
    how.clear();
    for(i=0;i<N;i++)
    {
        how.push_back(i+1);
        have[i+1]=0;
        xx[i+1]=i+1;
    }
    random_shuffle(xx+1,xx+N+1);

    for(i=0;i<N;i++)
    {
        for(jj=1;jj<=N;jj++)
        {
            j=xx[jj];
            if(!have[j])
            {
                how[i]=j;
                now=0;
                for(kk=1;kk<=N;kk++)
                {
                    k=xx[kk];
                    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:19:13: warning: unused variable 'c' [-Wunused-variable]
   19 |     int a,b,c,now,i,j,jj,kk,k,ok;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Correct! Number of queries: 25
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 256 KB Correct! Number of queries: 10
4 Correct 1 ms 256 KB Correct! Number of queries: 22
5 Correct 1 ms 256 KB Correct! Number of queries: 28
6 Correct 1 ms 256 KB Correct! Number of queries: 22
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Correct! Number of queries: 25
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 256 KB Correct! Number of queries: 10
4 Correct 1 ms 256 KB Correct! Number of queries: 22
5 Correct 1 ms 256 KB Correct! Number of queries: 28
6 Correct 1 ms 256 KB Correct! Number of queries: 22
7 Correct 26 ms 632 KB Correct! Number of queries: 1400
8 Correct 19 ms 632 KB Correct! Number of queries: 1200
9 Correct 12 ms 500 KB Correct! Number of queries: 1000
10 Correct 22 ms 632 KB Correct! Number of queries: 1200
11 Correct 20 ms 512 KB Correct! Number of queries: 1100
12 Correct 21 ms 632 KB Correct! Number of queries: 1300
13 Correct 18 ms 632 KB Correct! Number of queries: 1200
14 Correct 26 ms 632 KB Correct! Number of queries: 1200
15 Correct 23 ms 632 KB Correct! Number of queries: 1300
16 Correct 23 ms 632 KB Correct! Number of queries: 1400
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Correct! Number of queries: 25
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 256 KB Correct! Number of queries: 10
4 Correct 1 ms 256 KB Correct! Number of queries: 22
5 Correct 1 ms 256 KB Correct! Number of queries: 28
6 Correct 1 ms 256 KB Correct! Number of queries: 22
7 Correct 26 ms 632 KB Correct! Number of queries: 1400
8 Correct 19 ms 632 KB Correct! Number of queries: 1200
9 Correct 12 ms 500 KB Correct! Number of queries: 1000
10 Correct 22 ms 632 KB Correct! Number of queries: 1200
11 Correct 20 ms 512 KB Correct! Number of queries: 1100
12 Correct 21 ms 632 KB Correct! Number of queries: 1300
13 Correct 18 ms 632 KB Correct! Number of queries: 1200
14 Correct 26 ms 632 KB Correct! Number of queries: 1200
15 Correct 23 ms 632 KB Correct! Number of queries: 1300
16 Correct 23 ms 632 KB Correct! Number of queries: 1400
17 Runtime error 243 ms 19852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Halted 0 ms 0 KB -