답안 #315469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315469 2020-10-23T00:39:43 Z daniel920712 Mouse (info1cup19_mouse) C++14
0 / 100
4 ms 768 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};
bool have2[500]={0};

void solve(int N)
{
    int a,b,c,now,i,j,k;
    how.clear();
    for(i=0;i<N;i++)
    {
        how.push_back(i+1);
        have[i+1]=0;
        have2[i]=0;
    }
    for(i=0;i<N;i++)
    {
        //printf("aa\n");
        if(have2[i]) continue;
        for(j=1;j<=N;j++)
        {
            //printf("\n");
            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;

                for(k=i+1;k<N;k++)
                {
                    swap(how[i],how[k]);
                    b=query(how);
                    swap(how[i],how[k]);
                    if(b==N) return;
                    if(a-b==2)
                    {
                        have2[k]=1;
                        have[how[i]]=1;
                        have[how[k]]=1;
                        break;
                    }
                }
                if(a-b==2) break;




            }


        }
    }
}


Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:15:13: warning: unused variable 'c' [-Wunused-variable]
   15 |     int a,b,c,now,i,j,k;
      |             ^
mouse.cpp:60:21: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |                 if(a-b==2) break;
      |                    ~^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -