답안 #315491

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

using namespace std;
vector < int > how;
vector < int > ans;
bool have[500]={0};
set < int > all;
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[j]&&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);
                    swap(how[i],how[k]);
                    if(b==N) return;
                    //printf("%d %d %d %d\n",how[0],k,a,b);
                    if(a>b) continue;
                    else
                    {
                        ok=0;
                        break;
                    }
                }
                if(ok)
                {
                    //printf("aa\n");
                    //printf("aa %d %d\n",i,how[i]);
                    have[how[i]]=1;
                    break;
                }
            }
            else
            {
                swap(how[i],how[0]);
                b=query(how);
                swap(how[i],how[0]);
                if(b==N) return;
                if(a-b==2)
                {
                    //printf("bb %d %d\n",i,how[i]);
                    have[how[i]]=1;
                    break;
                }
            }



        }
    }
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:14:13: warning: unused variable 'c' [-Wunused-variable]
   14 |     int a,b,c,now,i,j,k,ok;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -