Submission #117179

# Submission time Handle Problem Language Result Execution time Memory
117179 2019-06-15T08:11:16 Z 임유진(#2871) Traffic (CEOI11_tra) C++14
32 / 100
61 ms 888 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

tra.cpp: In function 'int main()':
tra.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);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
tra.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);
                          ~~~~~^~~~~~~~~~~~~~~~~~
tra.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);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 572 KB Output is correct
2 Correct 61 ms 888 KB Output is correct
3 Correct 7 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -