Submission #1193456


Source Code Expand

Copy
#include<cstdio>
#include<cstdlib>
#include<cstring>

int N;
char input[10];
int time[482];

struct RainingTime{
	int begin, end;
};

void nuritsubushi(RainingTime input){
	int begin = input.begin / 5;
	int end = input.end / 5;
	//printf("begin: %d  end: %d\n",begin, end);
	for(int i = begin + 1;i <= end;i++){
		time[i] = 1;
	}
}

int CutUp(int num1){
	int sec1;
	if(num1 % 5 != 0)
	sec1 = num1 - (num1 % 5) + 5;
	else sec1 = num1;
	return sec1;
}

int CutDown(int num2){
	int sec2;
	sec2 = num2 - (num2 % 5);
	return sec2;
}

RainingTime GetTime(char str[]){
	char *token1, *token2;
	int begin_t, end_t;
	RainingTime OneRain;

	token1 = strtok(str, "-");
	token2 = strtok(NULL, "-");
	begin_t = atoi(token1);
	end_t = atoi(token2);

	begin_t = (begin_t / 100) * 60 + begin_t % 100;
	end_t = (end_t / 100) * 60 + end_t % 100;

	//printf("%d %d\n", begin_t, end_t);

	OneRain.begin = CutDown(begin_t);
	OneRain.end = CutUp(end_t);

	//printf("%d %d\n", OneRain.begin, OneRain.end);

	return OneRain;
}

int main(){
	char begintime[5], endtime[5];
	for(int i=0;i<=481;i++){
		time[i] = 0;
	}

	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%s",input);
		RainingTime inputs = GetTime(input);
		//printf("%d %d\n",inputs.begin, inputs.end);
		nuritsubushi(inputs);
	}
	for(int i=1;i<=480;i++){
		//printf("%d", time[i]);
		if(time[i-1] == 0 && time[i] == 1){
			int begin = ((i -1) * 5 / 60) * 100 + (((i - 1) * 5) % 60);
			sprintf(begintime, "%d", begin);
			int length = strlen(begintime);
			for(int i=1;i <= 4 - length;i++){
				printf("0");
			}
			printf("%d-", begin);
		}
		if(time[i] == 1 && time[i+1] == 0){
			int end = (i * 5 / 60) * 100 + (i * 5) % 60;
			sprintf(endtime, "%d", end);
			int length = strlen(endtime);
			for(int i = 1 ; i <= 4 - length ; i++){
				printf("0");
			}
			printf("%d\n",end);
		}
	}

	return 0;
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User utsumi
Language C++ (GCC 5.4.1)
Score 100
Code Size 1937 Byte
Status
Exec Time 12 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:65:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
                ^
./Main.cpp:67:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",input);
                    ^

Judge Result

Set Name Score / Max Score Test Cases
all 100 / 100 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt
Case Name Status Exec Time Memory
00_sample_01.txt 1 ms 128 KB
00_sample_02.txt 1 ms 128 KB
00_sample_03.txt 1 ms 128 KB
cho_cho_chokudai.txt 12 ms 128 KB
chokudai_ga_cho.txt 8 ms 128 KB
test_01.txt 1 ms 128 KB
test_02.txt 1 ms 128 KB
test_03.txt 1 ms 128 KB
test_04.txt 1 ms 128 KB
test_05.txt 1 ms 128 KB
test_06.txt 1 ms 128 KB
test_07.txt 1 ms 128 KB
test_08.txt 1 ms 128 KB
test_09.txt 1 ms 128 KB
test_10.txt 1 ms 128 KB
test_11.txt 1 ms 128 KB
test_12.txt 1 ms 128 KB
test_13.txt 1 ms 128 KB
test_14.txt 1 ms 128 KB
test_15.txt 1 ms 128 KB
test_16.txt 1 ms 128 KB
test_17.txt 1 ms 128 KB
test_18.txt 1 ms 128 KB
test_19.txt 1 ms 128 KB
test_20.txt 1 ms 128 KB
test_21.txt 7 ms 128 KB
test_22.txt 7 ms 128 KB
test_23.txt 7 ms 128 KB
test_24.txt 7 ms 128 KB
test_25.txt 7 ms 128 KB
test_26.txt 6 ms 128 KB
test_27.txt 6 ms 128 KB
test_28.txt 6 ms 128 KB
test_29.txt 1 ms 128 KB
test_30.txt 1 ms 128 KB
test_31.txt 1 ms 128 KB
test_32.txt 1 ms 128 KB
test_33.txt 4 ms 128 KB
test_34.txt 1 ms 128 KB
test_35.txt 1 ms 128 KB
test_36.txt 8 ms 128 KB
test_37.txt 6 ms 128 KB
test_38.txt 6 ms 128 KB
test_39.txt 6 ms 128 KB
test_40.txt 6 ms 128 KB
test_41.txt 9 ms 128 KB
test_42.txt 9 ms 128 KB
test_43.txt 9 ms 128 KB