Submission #962684

#TimeUsernameProblemLanguageResultExecution timeMemory
962684serkanrashid동굴 (IOI13_cave)C++14
100 / 100
245 ms852 KiB
#include "cave.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn = 5005;
 
int *s,*d;
int tekdoor;
 
int rec(vector<int>pos)
{
    if(pos.size()==1) return pos[0];
    int mid = (pos.size()-1)/2;
    for(int j = 0; j <= mid; j++) s[pos[j]] ^= 1;
    int ch = tryCombination(s);
    vector<int>nb;
    if(ch == tekdoor)
    {
        for(int j = mid+1; j < pos.size(); j++) nb.push_back(pos[j]);
        return rec(nb);
    }
    for(int j = 0; j <= mid; j++)
    {
        s[pos[j]] ^= 1;
        nb.push_back(pos[j]);
    }
    return rec(nb);
}
 
void exploreCave(int N)
{
    int ch;
    s = new int[N];
    d = new int[N];
    for(int i = 0; i < N; i++) d[i] = -1;
    for(int i = 0; i < N; i++)
    {
        vector<int>pos;
        for(int j = 0; j < N; j++)
        {
            if(d[j] == -1)
            {
                s[j] = 0;
                pos.push_back(j);
            }
        }
        ch = tryCombination(s);
        if(ch != i)
        {
            for(int j = 0; j < N; j++) if(d[j] == -1) s[j] = 1;
        }
        tekdoor = i;
        int idx = rec(pos);
        d[idx] = i;
        s[idx] ^= 1;
    }
    answer(s,d);
}

Compilation message (stderr)

cave.cpp: In function 'int rec(std::vector<int>)':
cave.cpp:20:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for(int j = mid+1; j < pos.size(); j++) nb.push_back(pos[j]);
      |                            ~~^~~~~~~~~~~~
#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...