Submission #1159256


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

vector<int> tempQue, timeQue;
int init, dest;
int solve();

int main(){
	scanf("%d %d", &init, &dest);
	cout << solve() << endl;
	return 0;
}

int solve() {
	int delta[] = {1, -1, 5, -5, 10, -10};
	int nowTemp, nowTime;
	tempQue.insert(tempQue.begin(), init); // 先頭に初期値を代入
	timeQue.insert(timeQue.begin(), 0); // 先頭に初期値を代入
	while( !tempQue.empty() ) {
		nowTemp = tempQue.back(); // 末尾要素を取り出し
		nowTime = timeQue.back();
		tempQue.pop_back(); // 末尾を消す
		timeQue.pop_back(); // 末尾を消す
		if( nowTemp == dest ) return nowTime;
		for(int i=0; i<6; i++){
			if( find(tempQue.begin(), tempQue.end(), nowTemp + delta[i]) == tempQue.end() ) { // キューにその値がない時
				tempQue.insert(tempQue.begin(), nowTemp + delta[i]);
				timeQue.insert(timeQue.begin(), nowTime + 1);
			}
		}
	}
	return 0;
}

Submission Info

Submission Time
Task B - リモコン
User obknnt0529
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1014 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &init, &dest);
                              ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 35
Set Name Test Cases
All 00_maxdiff.txt, 00_maxret.txt, 00_sample1.txt, 00_sample2.txt, 00_sample3.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 01_rnd_20.txt, 01_rnd_21.txt, 01_rnd_22.txt, 01_rnd_23.txt, 01_rnd_24.txt, 01_rnd_25.txt, 01_rnd_26.txt, 01_rnd_27.txt, 01_rnd_28.txt, 01_rnd_29.txt
Case Name Status Exec Time Memory
00_maxdiff.txt AC 1 ms 256 KB
00_maxret.txt AC 1 ms 256 KB
00_sample1.txt AC 1 ms 256 KB
00_sample2.txt AC 1 ms 256 KB
00_sample3.txt AC 1 ms 256 KB
01_rnd_00.txt AC 1 ms 256 KB
01_rnd_01.txt AC 1 ms 256 KB
01_rnd_02.txt AC 1 ms 256 KB
01_rnd_03.txt AC 1 ms 256 KB
01_rnd_04.txt AC 1 ms 256 KB
01_rnd_05.txt AC 1 ms 256 KB
01_rnd_06.txt AC 1 ms 256 KB
01_rnd_07.txt AC 1 ms 256 KB
01_rnd_08.txt AC 1 ms 256 KB
01_rnd_09.txt AC 1 ms 256 KB
01_rnd_10.txt AC 1 ms 256 KB
01_rnd_11.txt AC 1 ms 256 KB
01_rnd_12.txt AC 1 ms 256 KB
01_rnd_13.txt AC 1 ms 256 KB
01_rnd_14.txt AC 1 ms 256 KB
01_rnd_15.txt AC 1 ms 256 KB
01_rnd_16.txt AC 1 ms 256 KB
01_rnd_17.txt AC 1 ms 256 KB
01_rnd_18.txt AC 1 ms 256 KB
01_rnd_19.txt AC 1 ms 256 KB
01_rnd_20.txt AC 1 ms 256 KB
01_rnd_21.txt AC 1 ms 256 KB
01_rnd_22.txt AC 1 ms 256 KB
01_rnd_23.txt AC 1 ms 256 KB
01_rnd_24.txt AC 1 ms 256 KB
01_rnd_25.txt AC 1 ms 256 KB
01_rnd_26.txt AC 1 ms 256 KB
01_rnd_27.txt AC 1 ms 256 KB
01_rnd_28.txt AC 1 ms 256 KB
01_rnd_29.txt AC 1 ms 256 KB