제출 #123179

#제출 시각아이디문제언어결과실행 시간메모리
123179ekrem동굴 (IOI13_cave)C++98
100 / 100
1659 ms696 KiB
#include "cave.h" // #include <stdio.h> // #include <stdlib.h> // #define MAX_N 5000 // #define MAX_CALLS 70000 // /* Symbol obfuscation */ // #define NN koala // #define realS kangaroo // #define realD possum // #define inv platypus // #define num_calls echidna // static int NN; // static int realS[MAX_N]; // static int realD[MAX_N]; // static int inv[MAX_N]; // static int num_calls; // void answer(int S[], int D[]) { // int i; // int correct = 1; // for (i = 0; i < NN; ++i) // if (S[i] != realS[i] || D[i] != realD[i]) { // correct = 0; // break; // } // if (correct) // printf("CORRECT\n"); // else // printf("INCORRECT\n"); // for (i = 0; i < NN; ++i) { // if (i > 0) // printf(" "); // printf("%d", S[i]); // } // printf("\n"); // for (i = 0; i < NN; ++i) { // if (i > 0) // printf(" "); // printf("%d", D[i]); // } // printf("\n"); // exit(0); // } // int tryCombination(int S[]) { // int i; // if (num_calls >= MAX_CALLS) { // printf("INCORRECT\nToo many calls to tryCombination().\n"); // exit(0); // } // ++num_calls; // for (i = 0; i < NN; ++i) // if (S[inv[i]] != realS[inv[i]]) // return i; // return -1; // } // #include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define orta ((bas+son)/2) #define mod 1000000007 #define LOGN 16 #define N 1000005 using namespace std; typedef long long ll; int n, d, ne[N], c[N], s[N], ss[N], u[N], nee[N], cc[N]; int sor(int x){ int xx = 0; for(int i = 0; i < n; i++){ if(!u[i]){ ss[i] = s[xx]; xx++; } } for(int i = 0; i < x; i++) ss[c[i]] = ne[i]; int cvp = tryCombination(ss); return (cvp == -1)?n:cvp; } int bak(int x){ int xx = 0; for(int i = 0; i < n; i++){ if(!u[i]){ if(xx == x) return i; ss[i] = s[xx]; xx++; } } return mod; } void exploreCave(int nn) {n = nn; for(int i = 0; i < n; i++){ for(int j = 0; j < n - i; j++) s[j] = 0; int ilk = sor(i); for(int j = 0; j < n - i; j++) s[j] = 1; int iki = sor(i); d = (iki > ilk); ne[i] = d; int bas = 0, son = n - 1 - i; // cout << i << " " << bas << " " << son << endl; while(bas < son){ for(int j = 0; j <= orta; j++) s[j] = d; for(int j = orta + 1; j < n - i; j++) s[j] = 1 - d; if(sor(i) > i) son = orta; else bas = orta + 1; } c[i] = bak(orta); u[c[i]] = 1; } for(int i = 0; i < n; i++){ cc[c[i]] = i; nee[c[i]] = ne[i]; } answer(nee, cc); } // int init() { // int i, res; // FILE *f = fopen("in.txt", "r"); // res = fscanf(f, "%d", &NN); // for (i = 0; i < NN; ++i) { // res = fscanf(f, "%d", &realS[i]); // } // for (i = 0; i < NN; ++i) { // res = fscanf(f, "%d", &realD[i]); // inv[realD[i]] = i; // } // num_calls = 0; // return NN; // } // int main() { // freopen("out.txt", "w", stdout); // int NN; // NN = init(); // exploreCave(NN); // printf("INCORRECT\nYour solution did not call answer().\n"); // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...