AtCoder Beginner Contest 001

Submission #1193456

Source codeソースコード

#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

Task問題 D - 感雨時刻の整理
User nameユーザ名 utsumi
Created time投稿日時
Language言語 C++ (GCC 5.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 1937 Byte
File nameファイル名
Exec time実行時間 12 ms
Memory usageメモリ使用量 128 KB

Compiler messageコンパイルメッセージ

./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);
^

Test case

Set

Set name Score得点 / Max score 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 1 ms 128 KB
00_sample_02.txt AC 1 ms 128 KB
00_sample_03.txt AC 1 ms 128 KB
cho_cho_chokudai.txt AC 12 ms 128 KB
chokudai_ga_cho.txt AC 8 ms 128 KB
test_01.txt AC 1 ms 128 KB
test_02.txt AC 1 ms 128 KB
test_03.txt AC 1 ms 128 KB
test_04.txt AC 1 ms 128 KB
test_05.txt AC 1 ms 128 KB
test_06.txt AC 1 ms 128 KB
test_07.txt AC 1 ms 128 KB
test_08.txt AC 1 ms 128 KB
test_09.txt AC 1 ms 128 KB
test_10.txt AC 1 ms 128 KB
test_11.txt AC 1 ms 128 KB
test_12.txt AC 1 ms 128 KB
test_13.txt AC 1 ms 128 KB
test_14.txt AC 1 ms 128 KB
test_15.txt AC 1 ms 128 KB
test_16.txt AC 1 ms 128 KB
test_17.txt AC 1 ms 128 KB
test_18.txt AC 1 ms 128 KB
test_19.txt AC 1 ms 128 KB
test_20.txt AC 1 ms 128 KB
test_21.txt AC 7 ms 128 KB
test_22.txt AC 7 ms 128 KB
test_23.txt AC 7 ms 128 KB
test_24.txt AC 7 ms 128 KB
test_25.txt AC 7 ms 128 KB
test_26.txt AC 6 ms 128 KB
test_27.txt AC 6 ms 128 KB
test_28.txt AC 6 ms 128 KB
test_29.txt AC 1 ms 128 KB
test_30.txt AC 1 ms 128 KB
test_31.txt AC 1 ms 128 KB
test_32.txt AC 1 ms 128 KB
test_33.txt AC 4 ms 128 KB
test_34.txt AC 1 ms 128 KB
test_35.txt AC 1 ms 128 KB
test_36.txt AC 8 ms 128 KB
test_37.txt AC 6 ms 128 KB
test_38.txt AC 6 ms 128 KB
test_39.txt AC 6 ms 128 KB
test_40.txt AC 6 ms 128 KB
test_41.txt AC 9 ms 128 KB
test_42.txt AC 9 ms 128 KB
test_43.txt AC 9 ms 128 KB