Submission #3318

# Submission time Handle Problem Language Result Execution time Memory
3318 2013-08-30T11:38:01 Z yys1221 두 섬간의 연결 (kriii1_2) C
0 / 1
32 ms 1360 KB
#include <stdio.h>
#include <stdlib.h>
int main(){
	int number, i, j, temp, num_total, map[100000] = {0};
	int possible_case = 0, total_case = 0;
	int left, right;
	scanf("%d", &num_total);
	number = num_total-1;
	for(i=0;i<number;i++){
		scanf("%d", &temp);
		map[temp-1] = 1;
		left = 0;
		right = 0;
		for(j=temp-2;j>=0;j--){
			if(map[j]==0)
				break;
			left++;					
		}

		for(j=temp;j<num_total;j++){
			if(map[j]==0)
				break;
			right++;
		}
		if(left==0&& right==0){
			possible_case++;
			total_case++;
		}else{
			possible_case+=(right+1)*(left+1);
			total_case+=((right+left+1)*(right+left+2)/2-(left+1)*left/2)*(left+1)-left*(left+1)*(right+1)/2;
		}
		printf("%d %d\n", possible_case, total_case);
		printf("\n");
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1360 KB Output isn't correct
2 Halted 0 ms 0 KB -