hdu4529鄭廠長系列故事 N騎士問題

2021-06-24 11:23:32 字數 1048 閱讀 7524

#include #include #include #include #include #include #include using namespace std;

const int row = 9;

const int col = 8;

const int knight = 10 + 1; //其實上限

const int state = (1 << 8); //狀態上限

int cases, m, cur[row];

long long dp[2][knight][state][state], ans, cu, ne;

int results[state]; //儲存每個狀態的騎士數目

bool exista[state][state], existb[state][state]; //相鄰兩行是否能共存,相間兩行是否能共存.

char mt[row][col]; //儲存map

template bool read(t &n)

bool yes(int state, int i) //是否與皇后衝突

bool okone(int i, int j) //相鄰兩行是否衝突

bool okanother(int i, int j) //相間兩行是否衝突

void init()

}for (int i = 0; i < state; i++)

}for (int i = 0, a, temp; i < state; i++)

results[i] = temp;

}}void solve()}}

}memset(dp[cu], 0, sizeof(dp[cu]));

swap(cu, ne);

}for (int i = 0; i < state; i++)

}printf("%i64d\n", ans);

}void input()

}solve();

}}int main()

g++提交

hdu 4529 鄭廠長系列故事 N騎士問題

題目 狀態壓縮dp 好開心,終於會寫簡單的狀態dp了,雖然一開始用long long mle了 雖然第二次陣列開小了,開成dp 8 8 1 8 1 8 了 雖然二進位製用的還很戳,比如求1的個數 雖然.include include includeusing namespace std int t,...

鄭廠長系列故事 體檢

input 輸入的第一行為乙個正整數t,表示有t組測試資料 接下去有t組測試資料,每組測試資料佔一行,包含三個整數n,k,m,n表示員工的人數,k表示體檢的專案數,m表示醫生的人數。technical specification t 1000 1 n 100 1 k 10 1 m 100 outpu...

鄭廠長系列故事 新聞淨化 hdu4534

ac自動機 dp,此題有倆個優化目標 最少字母使文章符合要求,並讓加成分之和盡可能高,可以把倆個目標合併成乙個,即讓刪除乙個字母所獲得的加分為乙個很小的值 此題可以取 200000 這樣優化的目標即變為是的加分最大,最後再把結果分離即可。include include include include...