Submission #792968

# Submission time Handle Problem Language Result Execution time Memory
792968 2023-07-25T11:45:56 Z enerelt14 cmp (balkan11_cmp) C++14
100 / 100
1365 ms 96032 KB
#include "cmp.h"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

void remember(int a) {
	int pre = 0;
	for(int i = 5; i >= 0; i--) {
		int x = (a >> (2 * i)) & 3;
		pre *= 4;
		pre += x + 1;
		bit_set(pre);
	}
}

int compare(int b) {
	int pre = 0, pos[6];
	for(int i = 5; i >= 0; i--) {
		int x = (b >> (2 * i)) & 3;
		pre *= 4;
		pre += x + 1;
		pos[5 - i] = pre;
	}
	if(bit_get(pos[2])) {
		if(bit_get(pos[4])) {
			if(bit_get(pos[5])) {
				return 0;
			}
			else {
				if(pos[5] % 4 == 0) return 1;
				if(pos[5] % 4 == 1) return -1;
				if(pos[5] % 4 == 2) {
					if(bit_get(pos[5] - 1)) return 1;
					else return -1;
				}
				if(pos[5] % 4 == 3) {
					if(bit_get(pos[5] + 1)) return -1;
					else return 1;
				}
			}
		}
		else {
			if(bit_get(pos[3])) {
				if(pos[4] % 4 == 0) return 1;
				if(pos[4] % 4 == 1) return -1;
				if(pos[4] % 4 == 2) {
					if(bit_get(pos[4] - 1)) return 1;
					else return -1;
				}
				if(pos[4] % 4 == 3) {
					if(bit_get(pos[4] + 1)) return -1;
					else return 1;
				}
			}
			else {
				if(pos[3] % 4 == 0) return 1;
				if(pos[3] % 4 == 1) return -1;
				if(pos[3] % 4 == 2) {
					if(bit_get(pos[3] - 1)) return 1;
					else return -1;
				}
				if(pos[3] % 4 == 3) {
					if(bit_get(pos[3] + 1)) return -1;
					else return 1;
				}
			}
		}
	}
	else {
		if(bit_get(pos[1])) {
			if(pos[2] % 4 == 0) return 1;
			if(pos[2] % 4 == 1) return -1;
			if(pos[2] % 4 == 2) {
				if(bit_get(pos[2] - 1)) return 1;
				else return -1;
			}
			if(pos[2] % 4 == 3) {
				if(bit_get(pos[2] + 1)) return -1;
				else return 1;
			}
		}
		else {
			if(bit_get(pos[0])) {
				if(pos[1] % 4 == 0) return 1;
				if(pos[1] % 4 == 1) return -1;
				if(pos[1] % 4 == 2) {
					if(bit_get(pos[1] - 1)) return 1;
					else return -1;
				}
				if(pos[1] % 4 == 3) {
					if(bit_get(pos[1] + 1)) return -1;
					else return 1;
				}
			}
			else {
				if(pos[0] % 4 == 0) return 1;
				if(pos[0] % 4 == 1) return -1;
				if(pos[0] % 4 == 2) {
					if(bit_get(pos[0] - 1)) return 1;
					else return -1;
				}
				if(pos[0] % 4 == 3) {
					if(bit_get(pos[0] + 1)) return -1;
					else return 1;
				}
			}
		}
	}
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:125:1: warning: control reaches end of non-void function [-Wreturn-type]
  125 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1365 ms 96032 KB Output is correct - maxAccess = 10, score = 100