KakaoTalk_20190606_001802318.png
  • 246x0w
Welcome
Curriculum
Install&Go
Board
실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
  • 카테고리
  • 전체 게시물
  • 내 게시물
im020526
2020년 7월 19일
수정: 2020년 7월 19일

200719

게시판: 소스 코드 제출

/*

#include <iostream>

#include <vector>

using namespace std;

int num[101];

int total, connect;

vector<vector<int> > graph;


void f(int x, int y)

{

for(int i=0; i<=total; i++)

{

if(y+i>total) return;

if(graph[x][y+i]>0)

{

graph[x][y+i]--;

graph[y+i][x]--;

num[y+i]=1;

f(y+i,0);

}

}

}

int main()

{

int x, y;


cin>>total>>connect;


for(int i=0; i<=total+1; i++)

{

vector<int> v;

for(int j=0; j<=total+1; j++)

{

v.push_back(0);

}

graph.push_back(v);

}


for(int i=1; i<=connect; i++)

{

cin>>x>>y;

graph[x][y]=1;

graph[y][x]=1;

}


f(1,1);

int sum = 0;

num[1] = 0;

for(int i=1; i<=total; i++) {

sum += num[i];

}

cout << sum;

}

*/

#include <iostream>

#include <string>

#include <vector>

using namespace std;

vector<vector<int> > graph;

vector<int> ans;

vector<int> sol;

int num=1,N=1,answer,Num=2;


int solution(int n, vector<vector<int> > edge,int x)

{

for(int i=0; i<n; i++)

{

ans.push_back(0);

sol.push_back(0);

}

for(int j=1; j<=n; j++)

{

cout<<x<<' '<<j<<' '<<edge[x][j]<<endl;

if(edge[x][j]==1)

{

cout<<'N'<<endl;

sol[N++]=j;

ans[Num++]=num;

edge[x][j]=0;

edge[j][x]=0;

for(int i=1; i<=6; i++)

{

for(int j=1; j<=6; j++)

{

cout<<edge[i][j]<<' ';

}

cout<<endl;

}

}

}

num++;

x++;

solution(n,edge,sol[x]);

answer = 0;

return answer;

}


int main()

{

for(int i=0; i<=7; i++)

{

vector<int> v;

for(int j=0; j<=7; j++)

{

v.push_back(0);

}

graph.push_back(v);

}

graph[3][6]=1;

graph[4][3]=1;

graph[3][2]=1;

graph[1][3]=1;

graph[1][2]=1;

graph[2][4]=1;

graph[5][2]=1;


graph[6][3]=1;

graph[3][4]=1;

graph[2][3]=1;

graph[3][1]=1;

graph[2][1]=1;

graph[4][2]=1;

graph[2][5]=1;


solution(6,graph,1);


for(int i=1; i<=6; i++)

{

for(int j=1; j<=6; j++)

{

cout<<graph[i][j]<<' ';

}

cout<<endl;

}


cout<<answer;

}


댓글 0개
0
댓글
댓글 0개
유사 게시물
  • 200719
  • 200719
  • 220807
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호