알고리즘 문제 풀이/1DP_과제(~180615)
180215_10451_순열 사이클
//https://www.acmicpc.net/problem/10451 #include using namespace std;int graph[1001];bool visited[1001];int n; void init(){ for(int i=0; i> n; for(int i=1; i> graph[i];} void dfs(int now){ visited[now]=1; int next=graph[now]; if(!visited[next]) dfs(next);}int main(){ int t; cin >> t; while(t-->0){ init(); input(); int ans=0; for(int i=1; i