답안 #315248

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

using namespace std;
vector < vector < int > > all;
vector < int > con;
vector < int > how;

bool have[500]={0};
vector < int > tt;
int N,now=0,t;

int cmp(vector < int > a, vector < int > b)
{
    int i;
    int N=a.size(),con=0;
    for(i=0;i<N;i++) if(a[i]==b[i]) con++;
    return con;
}
bool F(int here)
{
    int ok=1,i,j,xx;
    if(here==N)
    {
        for(i=0;i<now;i++) if(tt[i]!=con[i]) ok=0;
        if(ok)
        {
            t=query(how);
            all.push_back(how);
            return 1;
        }
        return 0;
    }
    for(i=0;i<now;i++) if(tt[i]>con[i]) return 0;
    for(i=1;i<=N;i++)
    {
        if(!have[i])
        {
            how[here]=i;
            for(j=0;j<now;j++) if(all[j][here]==i) tt[j]++;
            have[i]=1;
            xx=F(here+1);
            have[i]=0;
            for(j=0;j<now;j++) if(all[j][here]==i) tt[j]--;
            if(xx) return 1;
        }
    }
    return 0;
}
void solve(int N)
{
    ::N=N;
    how.clear();
    all.clear();
    int i,now=0,x,ok=1;
    for(i=0;i<N;i++) how.push_back(i+1);
    while(t!=N)
    {
        for(i=0;i<N;i++) how[i]=i+1;
        x=0;
        for(auto i:all)
        {
            tt[x]=0;
            x++;
        }
        F(0);
        tt.push_back(0);
    }


}


Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:58:11: warning: unused variable 'now' [-Wunused-variable]
   58 |     int i,now=0,x,ok=1;
      |           ^~~
mouse.cpp:58:19: warning: unused variable 'ok' [-Wunused-variable]
   58 |     int i,now=0,x,ok=1;
      |                   ^~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3056 ms 1460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3056 ms 1460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3056 ms 1460 KB Time limit exceeded
2 Halted 0 ms 0 KB -