Merge branch 'master'
This commit is contained in:
commit
3f4d6cd144
|
@ -2,4 +2,4 @@
|
|||
.vscode/*
|
||||
template/*
|
||||
*.zip
|
||||
*/datas/*
|
||||
*/datas/*
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int state = 0;
|
||||
int v[16];
|
||||
char labels[4][16] = {"크뤼", "의", "鸞", "꽉"};
|
||||
int re[16];
|
||||
int xx[16];
|
||||
int k = 0;
|
||||
|
||||
void pt(int state) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
printf("%d ", (state >> i) & 1);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int validate_state(int state) {
|
||||
int *f = malloc(sizeof(int) * 4);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
f[i] = (state >> i) & 1;
|
||||
// printf("%d ", f[i]);
|
||||
}
|
||||
// printf("\n");
|
||||
if (!f[1] ^ f[2] && f[0] ^ f[1]) {
|
||||
return 0;
|
||||
} else if (!f[2] ^ f[3] && f[0] ^ f[2]) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int trans(int x, int undo) {
|
||||
// 0 깊刻크뤼菱성법붉
|
||||
// 1 깊刻던의법붉
|
||||
// 2 깊刻던鸞법붉
|
||||
// 3 깊刻던꽉법붉
|
||||
int tmp_state = state;
|
||||
if (x == 1) {
|
||||
tmp_state = state ^ 3;
|
||||
} else if (x == 2) {
|
||||
tmp_state = state ^ 5;
|
||||
} else if (x == 3) {
|
||||
tmp_state = state ^ 9;
|
||||
} else {
|
||||
tmp_state = state ^ 1;
|
||||
}
|
||||
// pt(state);
|
||||
// printf("%d > ", x);
|
||||
// pt(tmp_state);
|
||||
if (undo) {
|
||||
v[tmp_state] = 0;
|
||||
state = tmp_state;
|
||||
re[--k] = 0;
|
||||
xx[k] = 0;
|
||||
return 1;
|
||||
}
|
||||
if (validate_state(tmp_state) == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (v[tmp_state] == 0) {
|
||||
v[tmp_state] = 1;
|
||||
state = tmp_state;
|
||||
xx[k] = x;
|
||||
re[k++] = state;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dfs() {
|
||||
// printf(">> %d\n", state);
|
||||
if (state == 15) {
|
||||
for(int i = 0; i < k; i++) {
|
||||
printf("%d > ", xx[i]);
|
||||
pt(re[i]);
|
||||
}
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
if (trans(0, 0)) {
|
||||
dfs();
|
||||
trans(0, 1);
|
||||
}
|
||||
if (trans(1, 0)) {
|
||||
dfs();
|
||||
trans(1, 1);
|
||||
}
|
||||
if (trans(2, 0)) {
|
||||
dfs();
|
||||
trans(2, 1);
|
||||
}
|
||||
if (trans(3, 0)) {
|
||||
dfs();
|
||||
trans(3, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
// freopen("data.in", "r", stdin);
|
||||
// freopen("data.out", "w", stdout);
|
||||
v[0] = 1;
|
||||
dfs();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX_COLUMN 20
|
||||
#define MAX_ROW 20
|
||||
|
||||
typedef struct {
|
||||
int current_width;
|
||||
int current_height;
|
||||
int column_width[MAX_COLUMN];
|
||||
int row_height[MAX_ROW];
|
||||
|
||||
} TableInfo;
|
||||
|
||||
void init_table(int width, int height, TableInfo *table) {
|
||||
table->current_width = width;
|
||||
table->current_height = height;
|
||||
for (int i = 0; i < width; i++) {
|
||||
table->column_width[i] = 5;
|
||||
}
|
||||
for (int i = 0; i < height; i++) {
|
||||
table->row_height[i] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
void drawGUI(int currentSelection) {
|
||||
system("cls"); // 清除控制台屏幕
|
||||
|
||||
printf("======== GUI ========\n");
|
||||
printf("| |\n");
|
||||
printf("| [ ] [ ] |\n");
|
||||
printf("| |\n");
|
||||
printf("=====================\n");
|
||||
|
||||
if (currentSelection == 0) {
|
||||
printf(" ^ \n"); // 显示指向第一个方块被选中
|
||||
} else {
|
||||
printf(" \n");
|
||||
}
|
||||
|
||||
if (currentSelection == 1) {
|
||||
printf(" ^ \n"); // 显示指向第二个方块被选中
|
||||
} else {
|
||||
printf(" \n");
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int currentSelection = 0;
|
||||
int keyPressed;
|
||||
|
||||
while (1) {
|
||||
drawGUI(currentSelection);
|
||||
|
||||
keyPressed = getch(); // 获取键盘输入
|
||||
|
||||
if (keyPressed == 224) { // 特殊键
|
||||
keyPressed = getch(); // 获取特殊键码
|
||||
|
||||
if (keyPressed == 75) { // ←键
|
||||
currentSelection = (currentSelection - 1) % 2; // 向左选择方块
|
||||
} else if (keyPressed == 77) { // →键
|
||||
currentSelection = (currentSelection + 1) % 2; // 向右选择方块
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ans, a[10005];
|
||||
int n;
|
||||
int cx[100], zx[100], col[100];
|
||||
|
||||
void dfs(int x) {
|
||||
if (x > n) {
|
||||
ans++;
|
||||
if (ans <= 3) {
|
||||
for (int i = 1; i <= n; i++) {
|
||||
printf("%d ", a[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
int l = x + i, r = x - i + 15;
|
||||
if (cx[r] == 0 && zx[l] == 0 && col[i] == 0) {
|
||||
a[x] = i;
|
||||
cx[r] = 1;
|
||||
zx[l] = 1;
|
||||
col[i] = 1;
|
||||
dfs(x + 1);
|
||||
cx[r] = 0;
|
||||
zx[l] = 0;
|
||||
col[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
scanf("%d", &n);
|
||||
dfs(1);
|
||||
printf("%d", ans);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Ref: P1219 [USACO1.5] 八皇后 Checker Challenge
|
||||
// https://www.luogu.com.cn/record/40132197
|
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int rs[105],n,m,xcz;
|
||||
|
||||
int zj(int a){
|
||||
a++;
|
||||
if(a>n) a-=n;
|
||||
while(rs[a]==0&&xcz>0){
|
||||
a++;
|
||||
if(a>n) a-=n;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(){
|
||||
//freopen("title.txt","r",stdin);
|
||||
scanf("%d%d",&n,&m);
|
||||
xcz=n;
|
||||
for(int i=1;i<=n;i++) rs[i]=1;
|
||||
for(int i=m;xcz>0;){
|
||||
if(rs[i]==1){
|
||||
rs[i]=0;
|
||||
xcz--;
|
||||
printf("%d ",i);
|
||||
}
|
||||
int ls=m;
|
||||
while(ls--) i=zj(i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 尚未修改到课程版本
|
||||
// Ref: P1996 约瑟夫问题
|
Loading…
Reference in New Issue