답안 #117181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
117181 2019-06-15T08:20:31 Z 임유진(#2871) Treasure Hunt (CEOI11_tre) C++14
컴파일 오류
0 ms 0 KB
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

#define MAXN 6005
#define MAXM 6005

int x[MAXN], y[MAXN];
int c[MAXM], d[MAXM], k[MAXM];
vector<int> e[MAXN];
int l[MAXN], r[MAXN], ln, rn;
bool chk[MAXN];

bool cmp(int a, int b){
	return y[a]>y[b];
}

void dfs(int x){
	chk[x]=true;
	for(auto a:e[x]) if(!chk[a]) dfs(a);
}

int main(){
	int n, m, A, B;

	scanf("%d%d%d%d", &n, &m, &A, &B);
	if(n>MAXN||m>MAXM) return 0;
	for(int i=1; i<=n; i++) scanf("%d%d", x+i, y+i);
	for(int i=0; i<m; i++) scanf("%d%d%d", c+i, d+i, k+i);

	for(int i=0; i<m; i++){
		e[c[i]].push_back(d[i]);
		if(k[i]==2) e[d[i]].push_back(c[i]);
	}

	for(int i=1; i<=n; i++){
		if(x[i]==0) l[ln++]=i;
		if(x[i]==A) r[rn++]=i;
	}
	sort(l, l+ln, cmp);

	for(int i=0; i<ln; i++){
		for(int j=1; j<=n; j++) chk[j]=false;
		dfs(l[i]);
		int ans=0;
		for(int j=0; j<rn; j++) if(chk[r[j]]) ans++;
		printf("%d\n", ans);
	}

	return 0;
}

Compilation message

tre.cpp: In function 'int main()':
tre.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &n, &m, &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
tre.cpp:30:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%d%d", x+i, y+i);
                          ~~~~~^~~~~~~~~~~~~~~~~~
tre.cpp:31:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<m; i++) scanf("%d%d%d", c+i, d+i, k+i);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccLengsu.o: In function `main':
tregrader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccVo0QRn.o:tre.cpp:(.text.startup+0x0): first defined here
/tmp/ccLengsu.o: In function `main':
tregrader.cpp:(.text.startup+0x16): undefined reference to `init()'
tregrader.cpp:(.text.startup+0x61): undefined reference to `path(int, int)'
tregrader.cpp:(.text.startup+0xbd): undefined reference to `dig(int, int)'
collect2: error: ld returned 1 exit status