Submission #1101127

# Submission time Handle Problem Language Result Execution time Memory
1101127 2024-10-15T15:20:01 Z rainboy Machine (IOI24_machine) C++17
100 / 100
9 ms 592 KB
#include "machine.h"
#include <vector>

using namespace std;

typedef vector<int> vi;

const int L = 8;

vi find_permutation(int n) {
	vi aa(n);
	for (int i = 0; i < n; i++)
		aa[i] = i;
	if (n % 2 == 0) {
		int l = 0;
		while (1 << l + 1 <= n)
			l++;
		aa[(1 << l) - 1] = (n + 2 & n + 1) == 0 ? n + 2 : n;
	}
	vi pp = use_machine(aa);
	int x = 0;
	for (int l = 0; l < L; l++) {
		int d = 0;
		for (int i = 0; i < n; i++)
			d += (pp[i] & 1 << l) != 0 ? 1 : -1;
		if (d > 0)
			x ^= 1 << l;
	}
	for (int i = 0; i < n; i++)
		pp[i] ^= x;
	if (n % 2 == 0) {
		int l = 0;
		while (1 << l + 1 <= n)
			l++;
		for (int i = 0; i < n; i++)
			if (pp[i] >= n) {
				pp[i] = (1 << l) - 1;
				break;
			}
	}
  return pp;
}

Compilation message

machine.cpp: In function 'vi find_permutation(int)':
machine.cpp:16:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   16 |   while (1 << l + 1 <= n)
      |               ~~^~~
machine.cpp:18:25: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   18 |   aa[(1 << l) - 1] = (n + 2 & n + 1) == 0 ? n + 2 : n;
      |                       ~~^~~
machine.cpp:33:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   33 |   while (1 << l + 1 <= n)
      |               ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 5 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 5 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 4 ms 428 KB Output is correct
6 Correct 9 ms 424 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 5 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 592 KB Output is correct
6 Correct 6 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 508 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 4 ms 336 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 6 ms 424 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 3 ms 440 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 5 ms 440 KB Output is correct
6 Correct 5 ms 336 KB Output is correct
7 Correct 5 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 4 ms 448 KB Output is correct
6 Correct 5 ms 592 KB Output is correct
7 Correct 5 ms 592 KB Output is correct