Submission #4569
Source Code Expand
#include <bitset> #include <deque> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <algorithm> #include <functional> #include <iterator> #include <locale> #include <memory> #include <stdexcept> #include <utility> #include <string> #include <fstream> #include <ios> #include <iostream> #include <iosfwd> #include <iomanip> #include <istream> #include <ostream> #include <sstream> #include <streambuf> #include <complex> #include <numeric> #include <valarray> #include <exception> #include <limits> #include <new> #include <typeinfo> #include <cassert> #include <cctype> #include <cerrno> #include <cfloat> #include <climits> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdlib> #include <cstddef> #include <cstdarg> #include <ctime> #include <cstdio> #include <cstring> #include <cwchar> #include <cwctype> using namespace std; static const double EPS = 1e-8; static const double PI = 4.0 * atan(1.0); static const double PI2 = 8.0 * atan(1.0); typedef long long ll; typedef unsigned long long ull; #define ALL(c) (c).begin(), (c).end() #define CLEAR(v) memset(v,0,sizeof(v)) #define MP(a,b) make_pair((a),(b)) #define REP(i,n) for(int i=0;i<(int)n;++i) #define ABS(a) ((a)>0?(a):-(a)) template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; } template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; } template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; } template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; } const int diff[] = {-10, -5, -1, 1, 5, 10}; int solve(int A, int B) { set<int> open; set<int> close; open.insert(A); int answer = 1; while (true) { set<int> next; for (set<int>::iterator it = open.begin(), itEnd = open.end(); it != itEnd; ++it) { int from = *it; REP(i, 6) { int to = from + diff[i]; if (to == B) { return answer; } if (close.count(to)) { continue; } close.insert(to); next.insert(to); } } swap(open, next); ++answer; } } int main() { std::ios::sync_with_stdio(false); int A, B; cin >> A >> B; if (A == B) { cout << 0 << endl; return 0; } cout << solve(A, B) << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - センター採点 |
User | nodchip |
Language | C++ (GCC 4.4.7) |
Score | 0 |
Code Size | 2329 Byte |
Status | WA |
Exec Time | 2039 ms |
Memory | 43572 KB |
Judge Result
Set Name | all | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample1.txt, 00_sample2.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, 02_all_1.txt, 02_all_2.txt, 02_all_3.txt, 02_all_4.txt, 03_mini_1.txt, 03_mini_2.txt, 03_mini_3.txt, 03_mini_4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample1.txt | TLE | 2034 ms | 40484 KB |
00_sample2.txt | TLE | 2033 ms | 40588 KB |
01_rnd_00.txt | TLE | 2032 ms | 41484 KB |
01_rnd_01.txt | TLE | 2035 ms | 40592 KB |
01_rnd_02.txt | TLE | 2033 ms | 40844 KB |
01_rnd_03.txt | TLE | 2033 ms | 40716 KB |
01_rnd_04.txt | TLE | 2031 ms | 43444 KB |
01_rnd_05.txt | TLE | 2033 ms | 42928 KB |
01_rnd_06.txt | TLE | 2035 ms | 40484 KB |
01_rnd_07.txt | TLE | 2035 ms | 41356 KB |
01_rnd_08.txt | TLE | 2035 ms | 40844 KB |
01_rnd_09.txt | TLE | 2036 ms | 40192 KB |
01_rnd_10.txt | TLE | 2036 ms | 41356 KB |
01_rnd_11.txt | TLE | 2033 ms | 40836 KB |
01_rnd_12.txt | TLE | 2034 ms | 41100 KB |
01_rnd_13.txt | TLE | 2032 ms | 40972 KB |
01_rnd_14.txt | TLE | 2035 ms | 41720 KB |
01_rnd_15.txt | TLE | 2039 ms | 40352 KB |
01_rnd_16.txt | TLE | 2035 ms | 41228 KB |
01_rnd_17.txt | TLE | 2035 ms | 40716 KB |
01_rnd_18.txt | TLE | 2035 ms | 41476 KB |
01_rnd_19.txt | TLE | 2033 ms | 40848 KB |
02_all_1.txt | TLE | 2034 ms | 40448 KB |
02_all_2.txt | TLE | 2032 ms | 43052 KB |
02_all_3.txt | TLE | 2031 ms | 43572 KB |
02_all_4.txt | TLE | 2032 ms | 43052 KB |
03_mini_1.txt | WA | 20 ms | 128 KB |
03_mini_2.txt | WA | 18 ms | 128 KB |
03_mini_3.txt | WA | 18 ms | 128 KB |
03_mini_4.txt | WA | 20 ms | 128 KB |