Submission #315176

# Submission time Handle Problem Language Result Execution time Memory
315176 2020-10-22T03:52:18 Z Kevin_Zhang_TW Costinland (info1cup19_costinland) C++17
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
void kout(){ cerr << endl; }
template<class T1, class ...T2> void kout(T1 a, T2 ...e) { cerr << a << ' ', kout(e...); }
#else
#define DE(...) 0
#define deubg(...) 0
#endif
const int MAX_N = 111, wid1 = 4;
const ll inf = 1e18 + 10;
ll K;
char w[MAX_N][MAX_N];
ll way[MAX_N][MAX_N][2];
void add(ll &v, ll val) {
	v = min(inf, v + val);
}
bool check1() {
	memset(way, 0, sizeof(way));
	way[1][1][0] = 1;
	for (int i = 1;i <= wid1;++i)
		for (int j = 1;j <= wid1;++j) {
			ll sum = way[i][j][0] + way[i][j][1];
			if (sum > K) return false;
			if (w[i][j] == 'x') {
				add(way[i+1][j][0], sum);
				add(way[i][j+1][1], sum);
			}
			if (w[i][j] == 'r') 
				add(way[i][j+1][1], sum);
			if (w[i][j] == 'd')
				add(way[i+1][j][0], sum);
			if (w[i][j] == '.') {
				add(way[i+1][j][0], way[i][j][0]);
				add(way[i][j+1][1], way[i][j][1]);
			}
		}
	//DE(way[wid1][wid1][0] + way[wid1][wid1][1], K);
	return way[wid1][wid1][0] + way[wid1][wid1][1] == K;
}
bool dfs(int x, int y) {
	if (x == wid1 && y == wid1) 
		return w[x][y] = '.', check1();
	if (y > wid1)
		return dfs(x+1, 1);
	for (char s : {'r', 'd', 'x', '.'}) {
		if (x == 1 && y == 1 && s == '.') continue;
		if (y == wid1 && s == 'r') continue;
		if (x == wid1 && s == 'd') continue;
		w[x][y] = s;
		if (dfs(x, y+1))
			return true;
	}
	return false;
}
void subtask1() {
	assert(dfs(0,0));
	cout << wid1 << ' ' << wid1 << '\n';
	for (int i = 1;i <= wid1;++i)
		cout << w[i]+1 << '\n';
}
void subtask2() {
}

void logone(ll K) {
	int lev = __lg(--K);
	int n = lev + 2;
	for (int i = 1;i <= n;++i)
		for (int j = 1;j <= n;++j)
			w[i][j] = '.';
	for (int i = 1;i <= n;++i)
		w[i][n] = 'd', w[n][i] = 'r';

	w[1][1] = 'r';
	for (int i = 2;i < n;++i) {
		w[i][i] = 'x';
		w[i][i+1] = 'd';
		w[i+1][i] = 'r';
	}
	for (int i = 1, v = 1<<lev;i < n;++i) {
		if (K & v) w[1][i] = 'x';
		else w[1][i] = 'r';
	}
	for (int i = 1;i <= n;++i)
		cout << w[i]+1 << '\n';
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> K;
	logone(K);
	return 0;
//	if (K <= 19)
//		subtask1();
//	else
//		subtask2();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "xxd" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrd" found
2 Halted 0 ms 0 KB -