답안 #1103401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103401 2024-10-20T19:22:24 Z Tibi201 Mouse (info1cup19_mouse) C++14
0 / 100
1 ms 592 KB
#include <grader.h>
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <vector>
#include <time.h>
#define MAXN 256

int solved[MAXN];

std::set <int> cand[MAXN],used;
std::vector <int> q;
int ramase[MAXN];

void fill(int n){
    int i,j,n2;
    n2=n;
    for(i=0; i<n2; i++){
        ramase[i]=i+1;
    }
    for(auto x : used){
        ramase[x-1]=0;
    }
    for(i=0; i<n2; i++){
        if(ramase[i]==0){
            for(j=i+1; j<n2; j++){
                ramase[j-1]=ramase[j];
            }
            n2--;
        }
    }
    for(i=0; i<n; i++){
        if(solved[i]==0){
            j=rand()%n2;
            q[j]=ramase[j];
            for(j=j+1; j<n2; j++){
                ramase[j-1]=ramase[j];
            }
            n2--;
        }
    }
}

void solve(int N)
{
    srand(time(NULL));
    int i,j,x,n=N;
    auto y=used.begin();
    for(i=0; i<n; i++){
        for(j=1; j<=n; j++){
            cand[i].insert(j);
        }
    }
    for(i=0; i<n; i++){
        x=0;
        while(solved[x]==1)
            x++;
        for(j=x+1; j<n; j++){
            if((int)cand[j].size()<(int)cand[x].size())
                x=j;
        }
        y=cand[x].begin();
        y--;
        while((int)cand[i].size()>1){
            y++;
            if(y==cand[x].end())
                y=cand[x].begin();
            q[x+1]=*y;
            used.insert(*y);
            fill(n);
            if(query(q)==i){
                for(j=i; j<n; j++)
                    cand[j].erase(cand[j].find(q[j]));
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -