답안 #315787

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

using namespace std;
vector < int > how;
bool have[500]={0};
bool have2[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,where,cc;
    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)
                    {
                        where=k;
                        continue;
                    }
                    else
                    {
                        ok=0;
                        break;
                    }
                }
                if(ok)
                {
                    have[how[i]]=1;
                    have2[0]=1;
                    cc=0;
                    break;
                }
                else
                {
                    have[how[where]]=1;
                    have2[where]=1;
                    cc=where;
                    break;
                }
            }

        }
    }
    for(i=0;i<N;i++)
    {
        if(i==cc) continue;
        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;

            swap(how[i],how[cc]);
            b=Query(how);
            if(b==N) return;
            swap(how[i],how[cc]);
            if(a-b==2)
            {
                have[how[i]]=1;
                break;
            }

        }
    }
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:20:13: warning: unused variable 'c' [-Wunused-variable]
   20 |     int a,b,c,now,i,j,jj,kk,k,ok,where,cc;
      |             ^
mouse.cpp:81:33: warning: 'where' may be used uninitialized in this function [-Wmaybe-uninitialized]
   81 |                     have2[where]=1;
      |                     ~~~~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 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 3 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 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -