# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
341535 | 2020-12-29T23:22:42 Z | FlashGamezzz | 고대 책들 (IOI17_books) | C++11 | 793 ms | 1048580 KB |
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <vector> #include <utility> #include <deque> #include "books.h" using namespace std; bool valid(vector<int> v){ for (int i = 1; i < v.size(); i++){ if (v[i] < v[i-1]){ return false; } } return true; } long long minimum_walk(vector<int> p, int s) { deque<pair<pair<int, int>, pair<int, vector<int> > > > bfs; bfs.push_back(make_pair(make_pair(0, 0), make_pair(-1, p))); while (bfs.size() > 0){ int i = bfs.front().first.first, t = bfs.front().first.second, b = bfs.front().second.first; vector<int> v = bfs.front().second.second; bfs.pop_front(); if (i == 0 && b == -1 && valid(v)) return t; if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(b, v))); if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(b, v))); if (v[i] == -1){ vector<int> nv = v; nv[i] = b; if (i == 0 && valid(nv)) return t; if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(-1, nv))); if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(-1, nv))); } else { if (b == -1){ vector<int> nv = v; int temp = nv[i]; nv[i] = -1; if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(temp, nv))); if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv))); } else { vector<int> nv = v; int temp = nv[i]; nv[i] = b; if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(temp, nv))); if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv))); } } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 4 ms | 1900 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 6 ms | 1900 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 4 ms | 1900 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 492 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 4 ms | 1900 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 6 ms | 1900 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 4 ms | 1900 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 492 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Runtime error | 793 ms | 1048580 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 4 ms | 1900 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 6 ms | 1900 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 4 ms | 1900 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 492 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Runtime error | 793 ms | 1048580 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 670 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 4 ms | 1900 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 6 ms | 1900 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 4 ms | 1900 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 492 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Runtime error | 793 ms | 1048580 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Halted | 0 ms | 0 KB | - |