Submission #1310683

#TimeUsernameProblemLanguageResultExecution timeMemory
1310683dimitri.shengelia동굴 (IOI13_cave)C++20
0 / 100
16 ms504 KiB
#include <bits/stdc++.h>
#include "cave.h"

using namespace std;

int tryCombination ( int S[] );

void answer( int S[], int D[] );

void exploreCave( int n ) {

	int a[n], b[n];
	fill ( a, a + n, 0 );
	fill ( b, b + n, -1 );

	if ( n <= 100 ) {

		int k;

		while ( true ) {

			k = tryCombination( a );

			int lst = k;

			for ( int i = 0; i < n; i++ ) {

				a[i] = 1 - a[i];

				k = tryCombination( a );

				if ( k != -1 and k <= lst ) {

					b[i] = k;

				}

				a[i] = 1 - a[i];

			}

			k = tryCombination( a );

			if ( k == -1 ) {

				answer( a, b );

			}

			for ( int i = 0; i < n; i++ ) {

				if ( b[i] != -1 ) {

					continue;

				}

				a[i] = 0;

				k = tryCombination( a );

				if ( k > lst or k == -1 ) {

					break;

				}

				a[i] = 1;

				k = tryCombination( a );

				if ( k > lst or k == -1 ) {

					break;

				}

			}

		}

		return;

	}

	if ( tryCombination ( a ) != -1 ) {

		for ( int i = 0; i < n; i++ ) {

			a[i] = 0;

			b[i] = i;

			if ( tryCombination ( a ) == i ) {

				a[i] = 1;

			}

		}

		answer( a, b );

	} else {

		for ( int i = 0; i < n; i++ ) {

			a[i] = 1;

			b[i] = tryCombination ( a );

			a[i] = 0;

		}

		answer( a, b );

	}

	return;

}
#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...