UVA Solution 291 - The House Of Santa Claus - Solution in C++ | Volume 2
UVA Online Judge Solution 291 - The House Of Santa Claus| Volume 2
UVA Problem Link - 291 - The House Of Santa Claus - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=4&page=show_problem&problem=227
Problem Name: 291 - The House Of Santa Claus
Problem Number : UVA - 291 - The House Of Santa Claus
Online Judge : UVA Online Judge Solution
Volume: 2
Solution Language : C plus plus
UVA Solution 291 - The House Of Santa Claus Code in CPP:
#include <stdio.h> int map[5][5] = { {0,1,1,0,1}, {1,0,1,0,1}, {1,1,0,1,1}, {0,0,1,0,1}, {1,1,1,1,0} }; int ans[8] = {0}; void DFS(int idx, int now) { ans[idx] = now; if(idx == 8) { for(int i = 0; i < 9; i++) printf("%d", ans[i]+1); puts(""); return ; } int i; for(i = 0; i < 5; i++) { if(map[now][i] == 1) { map[now][i] = map[i][now] = 0; DFS(idx+1, i); map[now][i] = map[i][now] = 1; } } } int main() { DFS(0, 0); return 0; }
No comments:
Post a Comment