답안 #132572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
132572 2019-07-19T07:37:05 Z 이온조(#3199) Friends (BOI17_friends) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int N, p, q, low[2509], dfn[2509], t;
bool chk[2509][2509];
vector<int> adj[2509], S;
vector<vector<int> > bcc;



void dfs(int x) {
	S.push_back(x);
	low[x] = dfn[x] = ++t;
	for(auto& it: adj[x]) {
		if(!chk[x][it]) continue;

		if(dfn[it]) low[]
	}
}

void go() {
	t = 0;
	fill(low, low+N, 0); fill(dfn, dfn+N, 0);
	bcc.clear();
	S.clear();
	dfs(1);
	for(auto& it: bcc) if((int)it.size() > p) return;
	puts("home");
	printf("%d\n", bcc.size());
	for(auto& it: bcc) {
		printf("%d ", it.size());
		for(auto& jt: it) printf("%d ", jt);
		puts("");
	}
	exit(0);
}

int main() {
	scanf("%d%d%d",&N,&p,&q);
	for(int i=0; i<N; i++) {
		int m; scanf("%d",&m);
		for(int j=0; j<m; j++) {
			int foo; scanf("%d",&foo);
			adj[i].push_back(foo);
		}
	}
	for(int i=0; i<N; i++) for(int j=0; j<N; j++) if(chk[i][j] && !chk[j][i]) fail();
	go();
	for(int i=0; i<N; i++) for(auto& it: adj[i]) {
		chk[i][it] = chk[it][i] = 0;
		go();
		chk[i][it] = chk[it][i] = 1;
	}
	fail();
	return 0;
}

Compilation message

friends.cpp: In function 'void dfs(int)':
friends.cpp:17:19: error: expected primary-expression before ']' token
   if(dfn[it]) low[]
                   ^
friends.cpp: In function 'void go()':
friends.cpp:29:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::vector<int> >::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", bcc.size());
                 ~~~~~~~~~~^
friends.cpp:31:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
   printf("%d ", it.size());
                 ~~~~~~~~~^
friends.cpp: In function 'int main()':
friends.cpp:47:76: error: 'fail' was not declared in this scope
  for(int i=0; i<N; i++) for(int j=0; j<N; j++) if(chk[i][j] && !chk[j][i]) fail();
                                                                            ^~~~
friends.cpp:47:76: note: suggested alternative: 'main'
  for(int i=0; i<N; i++) for(int j=0; j<N; j++) if(chk[i][j] && !chk[j][i]) fail();
                                                                            ^~~~
                                                                            main
friends.cpp:54:2: error: 'fail' was not declared in this scope
  fail();
  ^~~~
friends.cpp:54:2: note: suggested alternative: 'main'
  fail();
  ^~~~
  main
friends.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&N,&p,&q);
  ~~~~~^~~~~~~~~~~~~~~~~~~
friends.cpp:41:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int m; scanf("%d",&m);
          ~~~~~^~~~~~~~~
friends.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int foo; scanf("%d",&foo);
             ~~~~~^~~~~~~~~~~