답안 #930695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930695 2024-02-20T09:35:23 Z socpite Mouse (info1cup19_mouse) C++14
35.3077 / 100
3000 ms 732 KB
#include<bits/stdc++.h>
#include"grader.h"
using namespace std;

const int maxn = 260;
int MAGIC = 10;

mt19937 rng(69420);

int n = 260;

vector<int> crr;

int cnt[maxn][maxn];
int pp[maxn][maxn];

vector<vector<int>> amon;
vector<int> perm;

void backtrack(int pos) {
    if(pos == n+1){
        amon.push_back(crr);
        return;
    }
    for(int i = 0; i < n; i++){
        if(crr[i]){
            continue;
        }
        bool chk = 1;
        for(int j = 0; j < MAGIC; j++){
            int tmp = i - pp[j][pos];
            tmp*=-1;
            if(tmp < 0)tmp += n;
            if(!cnt[j][tmp]){
                
                chk = 0;
                break;
            } 
        }
        if(!chk)continue;
        for(int j = 0; j < MAGIC; j++){
            int tmp = i - pp[j][pos];
            tmp*=-1;
            if(tmp < 0)tmp += n;
            cnt[j][tmp]--;
        }
        crr[i] = pos;
        backtrack(pos+1);
        crr[i] = 0;
        for(int j = 0; j < MAGIC; j++){
            int tmp = i - pp[j][pos];
            tmp*=-1;
            if(tmp < 0)tmp += n;
            cnt[j][tmp]++;
        }
    }
}


void solve (int N){
    n = N;
    ios::sync_with_stdio(false);
    cin.tie(0);
    crr.assign(n, 0);
    for(int i = 1; i <= n; i++)perm.push_back(i);
    shuffle(perm.begin(), perm.end(), rng);
    vector<int> rd = perm;
    for(int i = 0; i < MAGIC; i++){
        shuffle(rd.begin(), rd.end(), rng);
        for(int j = 0; j < n; j++)pp[i][rd[j]] = j;
        for(int j = 0; j < n; j++){
            cnt[i][j] = query(rd);
            if(cnt[i][j] == n)return;
            rd.push_back(rd[0]);
            rd.erase(rd.begin());
        }
    }
    backtrack(1);
    query(amon[0]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Correct! Number of queries: 71
2 Correct 1 ms 464 KB Correct! Number of queries: 41
3 Correct 0 ms 468 KB Correct! Number of queries: 61
4 Correct 1 ms 464 KB Correct! Number of queries: 71
5 Correct 1 ms 468 KB Correct! Number of queries: 71
6 Correct 1 ms 468 KB Correct! Number of queries: 71
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Correct! Number of queries: 71
2 Correct 1 ms 464 KB Correct! Number of queries: 41
3 Correct 0 ms 468 KB Correct! Number of queries: 61
4 Correct 1 ms 464 KB Correct! Number of queries: 71
5 Correct 1 ms 468 KB Correct! Number of queries: 71
6 Correct 1 ms 468 KB Correct! Number of queries: 71
7 Correct 5 ms 464 KB Correct! Number of queries: 600
8 Correct 3 ms 720 KB Correct! Number of queries: 600
9 Correct 3 ms 720 KB Correct! Number of queries: 500
10 Correct 3 ms 732 KB Correct! Number of queries: 600
11 Correct 3 ms 468 KB Correct! Number of queries: 500
12 Correct 3 ms 724 KB Correct! Number of queries: 500
13 Correct 3 ms 476 KB Correct! Number of queries: 500
14 Correct 3 ms 720 KB Correct! Number of queries: 600
15 Correct 4 ms 468 KB Correct! Number of queries: 600
16 Correct 4 ms 720 KB Correct! Number of queries: 600
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Correct! Number of queries: 71
2 Correct 1 ms 464 KB Correct! Number of queries: 41
3 Correct 0 ms 468 KB Correct! Number of queries: 61
4 Correct 1 ms 464 KB Correct! Number of queries: 71
5 Correct 1 ms 468 KB Correct! Number of queries: 71
6 Correct 1 ms 468 KB Correct! Number of queries: 71
7 Correct 5 ms 464 KB Correct! Number of queries: 600
8 Correct 3 ms 720 KB Correct! Number of queries: 600
9 Correct 3 ms 720 KB Correct! Number of queries: 500
10 Correct 3 ms 732 KB Correct! Number of queries: 600
11 Correct 3 ms 468 KB Correct! Number of queries: 500
12 Correct 3 ms 724 KB Correct! Number of queries: 500
13 Correct 3 ms 476 KB Correct! Number of queries: 500
14 Correct 3 ms 720 KB Correct! Number of queries: 600
15 Correct 4 ms 468 KB Correct! Number of queries: 600
16 Correct 4 ms 720 KB Correct! Number of queries: 600
17 Execution timed out 3041 ms 728 KB Time limit exceeded
18 Halted 0 ms 0 KB -