發表文章

目前顯示的是有「brute-force」標籤的文章

[TIOJ] 1994. 冰塊線

題目連結: http://tioj.infor.org/problems/1994 就照著做,分成左上左下右上右下四塊遞迴下去,但是很噁心,要判一些case QQ,賽中寫了2hr,然後就沒時間寫其他題了 #include <bits/stdc++.h> using namespace std; const int N = 1<<11; const int A=0, B=1, C=2, D=3, E=4; int n; int ans[N][N]; void dfs(int,int,int,int,int,int); int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n; int sz = 1<<n; dfs(0, 0, sz, sz, 0, B); for(int i=0;i<sz;i++) for(int j=0;j<sz;j++){ cout<<ans[i][j]<<" \n"[j==sz-1]; } return 0; } void dfs(int l, int u, int r, int d, int x, int f){ if(r-l==1){ ans[l][u]=x; return; } int hal = (r-l)>>1; if(f==A){ dfs(l, u, r-hal, d-hal, x, B); dfs(l+hal, u, r, d-hal, x+hal*hal*3, E); dfs(l+hal, u+hal, r, d, x+hal*hal*2, A); dfs(l, u+hal, r-hal, d, x+hal*hal*1,...