Submission #525209

# Submission time Handle Problem Language Result Execution time Memory
525209 2022-02-11T05:08:14 Z amunduzbaev Navigation 2 (JOI21_navigation2) C++17
0 / 100
0 ms 196 KB
#include "Anna.h"
#include "bits/stdc++.h"
using namespace std;

void Anna(int n, int k, vector<int> r, vector<int> c) {
	vector<vector<int>> f(n, vector<int>(n, -1));
	vector<vector<int>> t(n, vector<int>(n));
	for(int i=0;i<k;i++) t[r[i]][c[i]] = i + 1;
	//~ for(int i=0;i<n;i++){
		//~ for(int j=0;j<n;j++){
			//~ cout<<t[i][j]<<" ";
		//~ } cout<<"\n";
	//~ } cout<<"\n";
	
	int ch[9][2] = {
		{-1, -1},
		{-1, 0},
		{-1, 1},
		{0, -1},
		{0, 0},
		{0, 1},
		{1, -1},
		{1, 0},
		{1, 1}
	};
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int in = ((i%3) * 3 + j) % 7;
			if(c[in] > j + 1){
				f[i][j] = 0;
			} else if(r[in] > i + 1){
				f[i][j] = 2;
			} else if(c[in] < j - 1){
				f[i][j] = 1;
			} else if(r[in] < i - 1){
				f[i][j] = 3;
			} else {
				for(int t=0;t<9;t++){
					int x = i + ch[t][0], y = j + ch[t][1];
					if(r[in] == x && c[in] == y){
						f[i][j] = t + 4;
					}
				}
			} if(in == 0){
				f[i][j] += 13;
			}
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			assert(~f[i][j]);
			SetFlag(i, j, f[i][j] + 1);
		}
	}
}
#include "Bruno.h"
#include "bits/stdc++.h"
using namespace std;
#define ar array

vector<int> Bruno(int k, vector<int> val) {
	vector<int> r(k), ii(9);
	ar<int, 2> ch[9] = {
		{-1, -1},
		{-1, 0},
		{-1, 1},
		{0, -1},
		{0, 0},
		{0, 1},
		{1, -1},
		{1, 0},
		{1, 1}
	};
	
	ar<int, 2> p = {-2};
	for(int i=0;i<9;i++){ val[i]--;
		if(val[i] >= 13){
			val[i] -= 13;
			p = ch[i];
		}
	} assert(p[0] != -2);
	
	int tt[5][5] = {
		{6, 0, 1, 2, 3},
		{2, 3, 4, 5, 6},
		{5, 6, 0, 1, 2},
		{1, 2, 3, 4, 5},
		{4, 5, 6, 0, 1},
	};
	for(int i=0;i<9;i++){
		int x = p[0] - ch[i][0] + 2, y = p[1] - ch[i][1] + 2;
		ii[i] = tt[x][y];
	}
	for(int i=0;i<9;i++){ 
		int in = ii[i] % 7, f = val[i];
		if(f < 4) r[in] = f;
		else { f -= 4;
			int x = ch[i][0] + ch[f][0], y = ch[i][1] + ch[f][1];
			if(y > 0) r[in] = 0;
			else if(x > 0) r[in] = 2;
			else if(y < 0) r[in] = 1;
			else if(x < 0) r[in] = 3;
			else r[in] = 4;
		}
	} 
	
	//~ for(int i=0;i<k;i++) cout<<r[i]<<" ";
	//~ cout<<"\n";
	return r;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 196 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -