Submission #318794

# Submission time Handle Problem Language Result Execution time Memory
318794 2020-11-03T08:44:55 Z jerrymonkey Cave (IOI13_cave) C++14
0 / 100
321 ms 364 KB
#include "cave.h"
#include <bits/stdc++.h>

using namespace std;


void exploreCave (int N) {
    int known[N], correctSw[N];
    for (int i = 0; i < N; i++)
		known[i] = -1;

    for (int i = 0; i < N; i++) {
        int segLen = pow(2, __lg(N - i - 1));
		int output[N];
		for (int i = 0; i < N; i++)
			output[i] = known[i];
        bool f = false;
        int c = 0, pos = 0;
		for (int j = 0; j < N; j++) {
			if (output[j] == -1)
				output[j] = 0;
		}
		bool doorSw = 0;
		if (tryCombination(output) > i)
			doorSw = 0;
		else
			doorSw = 1;
        while (1) {
			for (int j = 0; j < N; j++) {
				if (output[j] == -1) {
					output[j] = ((c / segLen + doorSw) % 2);
					c++;
				}
			}
			if (!tryCombination(output) > i)
                pos = pos | (1 << __lg(segLen));
			if (segLen == 1)
				break;
			segLen /= 2;
        }

		int k = 0;
        for (int j = 0; j < N; j++) {
            if (known[j] == -1) {
                if (k == pos) {
					known[j] = doorSw;
					correctSw[doorSw] = i;
					break;
                }
                k++;
            }
        }

	}

    answer(known, correctSw);


}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:35:32: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
   35 |    if (!tryCombination(output) > i)
      |                                ^
cave.cpp:35:8: note: add parentheses around left hand side expression to silence this warning
   35 |    if (!tryCombination(output) > i)
      |        ^~~~~~~~~~~~~~~~~~~~~~~
      |        (                      )
cave.cpp:17:14: warning: unused variable 'f' [-Wunused-variable]
   17 |         bool f = false;
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 287 ms 364 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 321 ms 364 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 287 ms 364 KB Answer is wrong
2 Halted 0 ms 0 KB -