답안 #134269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134269 2019-07-22T10:18:32 Z claudy Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
395 ms 241136 KB
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

/*
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
Tree<int>tr;
*/

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# define sim template < class c
# define ris return * this
# define dor > debug & operator <<
# define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int n,m,x[30005],p[30005],dist[30005],viz[30005];
bitset<30005>b[50005];
vector<int>vec[30005];

int32_t main(){_
	//freopen("input","r",stdin);
	cin >> n >> m;
	for(int i = 0;i < m;i++)
	{
		cin >> x[i] >> p[i];
		vec[x[i]].pb(p[i]);
	}
	for(int i = 0;i < n;i++)
	{
		dist[i] = 1e9;
	}
	b[0][x[0]] = 1;
	for(int i = 0;i <= 50000;i++)
	{
		for(int j = b[i]._Find_first();j < sz(b[i]);j = b[i]._Find_next(j))
		{
			if(dist[j] == 1e9)
			{
				dist[j] = i;
				for(auto it : vec[j])
				{
					for(int k = (j / it) * (-1);k <= (n - j) / it;k++)
					{
						if(k) b[i + abs(k)][j + k * it] = 1;
					}
				}
			}
		}
	}
	if(dist[x[1]] == 1e9) rc(-1);
	rc(dist[x[1]]);
	return 0;
}









Compilation message

skyscraper.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 # pragma GCC optimization ("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 1400 KB Output is correct
2 Correct 71 ms 1400 KB Output is correct
3 Correct 70 ms 1352 KB Output is correct
4 Correct 70 ms 1556 KB Output is correct
5 Correct 72 ms 1528 KB Output is correct
6 Correct 72 ms 1452 KB Output is correct
7 Correct 71 ms 1412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 1500 KB Output is correct
2 Correct 71 ms 1384 KB Output is correct
3 Correct 71 ms 1400 KB Output is correct
4 Correct 71 ms 1528 KB Output is correct
5 Correct 70 ms 1528 KB Output is correct
6 Correct 70 ms 1528 KB Output is correct
7 Correct 71 ms 1528 KB Output is correct
8 Correct 71 ms 1540 KB Output is correct
9 Correct 71 ms 1692 KB Output is correct
10 Correct 72 ms 1784 KB Output is correct
11 Correct 71 ms 1784 KB Output is correct
12 Correct 72 ms 2300 KB Output is correct
13 Correct 75 ms 2220 KB Output is correct
14 Correct 71 ms 1884 KB Output is correct
15 Correct 72 ms 1784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1376 KB Output is correct
2 Correct 71 ms 1400 KB Output is correct
3 Correct 70 ms 1400 KB Output is correct
4 Correct 70 ms 1372 KB Output is correct
5 Correct 71 ms 1400 KB Output is correct
6 Correct 70 ms 1400 KB Output is correct
7 Correct 70 ms 1492 KB Output is correct
8 Correct 71 ms 1628 KB Output is correct
9 Correct 73 ms 1656 KB Output is correct
10 Correct 72 ms 1784 KB Output is correct
11 Correct 73 ms 1788 KB Output is correct
12 Correct 73 ms 2276 KB Output is correct
13 Correct 72 ms 2168 KB Output is correct
14 Correct 71 ms 1808 KB Output is correct
15 Correct 71 ms 1912 KB Output is correct
16 Correct 71 ms 1400 KB Output is correct
17 Correct 74 ms 4124 KB Output is correct
18 Correct 71 ms 1528 KB Output is correct
19 Correct 72 ms 1700 KB Output is correct
20 Correct 110 ms 16248 KB Output is correct
21 Correct 72 ms 1500 KB Output is correct
22 Correct 71 ms 1384 KB Output is correct
23 Correct 72 ms 4572 KB Output is correct
24 Correct 73 ms 4600 KB Output is correct
25 Correct 83 ms 16292 KB Output is correct
26 Correct 102 ms 19324 KB Output is correct
27 Correct 98 ms 19580 KB Output is correct
28 Correct 108 ms 73976 KB Output is correct
29 Correct 77 ms 13816 KB Output is correct
30 Correct 76 ms 12024 KB Output is correct
31 Correct 77 ms 13148 KB Output is correct
32 Correct 78 ms 15992 KB Output is correct
33 Correct 78 ms 13944 KB Output is correct
34 Correct 79 ms 8916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 1468 KB Output is correct
2 Correct 71 ms 1480 KB Output is correct
3 Correct 71 ms 1400 KB Output is correct
4 Correct 70 ms 1460 KB Output is correct
5 Correct 71 ms 1408 KB Output is correct
6 Correct 70 ms 1400 KB Output is correct
7 Correct 71 ms 1500 KB Output is correct
8 Correct 70 ms 1516 KB Output is correct
9 Correct 77 ms 1656 KB Output is correct
10 Correct 72 ms 1912 KB Output is correct
11 Correct 71 ms 1784 KB Output is correct
12 Correct 72 ms 2268 KB Output is correct
13 Correct 72 ms 2160 KB Output is correct
14 Correct 71 ms 1912 KB Output is correct
15 Correct 71 ms 1872 KB Output is correct
16 Correct 71 ms 1528 KB Output is correct
17 Correct 73 ms 4088 KB Output is correct
18 Correct 71 ms 1400 KB Output is correct
19 Correct 71 ms 1468 KB Output is correct
20 Correct 121 ms 16248 KB Output is correct
21 Correct 71 ms 1484 KB Output is correct
22 Correct 71 ms 1388 KB Output is correct
23 Correct 73 ms 4576 KB Output is correct
24 Correct 73 ms 4728 KB Output is correct
25 Correct 79 ms 16248 KB Output is correct
26 Correct 96 ms 19436 KB Output is correct
27 Correct 93 ms 19576 KB Output is correct
28 Correct 106 ms 73976 KB Output is correct
29 Correct 77 ms 13816 KB Output is correct
30 Correct 76 ms 12024 KB Output is correct
31 Correct 77 ms 13048 KB Output is correct
32 Correct 79 ms 15992 KB Output is correct
33 Correct 78 ms 13788 KB Output is correct
34 Correct 76 ms 8956 KB Output is correct
35 Correct 81 ms 7032 KB Output is correct
36 Correct 74 ms 4344 KB Output is correct
37 Correct 81 ms 8824 KB Output is correct
38 Correct 84 ms 9464 KB Output is correct
39 Correct 85 ms 9336 KB Output is correct
40 Correct 84 ms 9436 KB Output is correct
41 Correct 85 ms 9464 KB Output is correct
42 Correct 351 ms 20048 KB Output is correct
43 Correct 329 ms 20276 KB Output is correct
44 Correct 395 ms 16760 KB Output is correct
45 Correct 93 ms 14456 KB Output is correct
46 Correct 87 ms 9440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 1528 KB Output is correct
2 Correct 71 ms 1400 KB Output is correct
3 Correct 72 ms 1372 KB Output is correct
4 Correct 70 ms 1368 KB Output is correct
5 Correct 71 ms 1528 KB Output is correct
6 Correct 71 ms 1400 KB Output is correct
7 Correct 71 ms 1524 KB Output is correct
8 Correct 71 ms 1528 KB Output is correct
9 Correct 71 ms 1736 KB Output is correct
10 Correct 71 ms 1812 KB Output is correct
11 Correct 71 ms 1756 KB Output is correct
12 Correct 72 ms 2296 KB Output is correct
13 Correct 72 ms 2328 KB Output is correct
14 Correct 72 ms 1912 KB Output is correct
15 Correct 72 ms 1784 KB Output is correct
16 Correct 71 ms 1568 KB Output is correct
17 Correct 73 ms 4044 KB Output is correct
18 Correct 71 ms 1528 KB Output is correct
19 Correct 71 ms 1528 KB Output is correct
20 Correct 111 ms 16248 KB Output is correct
21 Correct 71 ms 1528 KB Output is correct
22 Correct 71 ms 1596 KB Output is correct
23 Correct 87 ms 4600 KB Output is correct
24 Correct 73 ms 4728 KB Output is correct
25 Correct 79 ms 16248 KB Output is correct
26 Correct 96 ms 19320 KB Output is correct
27 Correct 92 ms 19596 KB Output is correct
28 Correct 105 ms 73984 KB Output is correct
29 Correct 77 ms 13820 KB Output is correct
30 Correct 76 ms 11896 KB Output is correct
31 Correct 77 ms 13048 KB Output is correct
32 Correct 78 ms 15992 KB Output is correct
33 Correct 78 ms 13744 KB Output is correct
34 Correct 75 ms 8952 KB Output is correct
35 Correct 81 ms 7064 KB Output is correct
36 Correct 73 ms 4344 KB Output is correct
37 Correct 82 ms 8700 KB Output is correct
38 Correct 85 ms 9492 KB Output is correct
39 Correct 86 ms 9228 KB Output is correct
40 Correct 87 ms 9592 KB Output is correct
41 Correct 89 ms 9464 KB Output is correct
42 Correct 372 ms 20020 KB Output is correct
43 Correct 287 ms 20344 KB Output is correct
44 Correct 394 ms 16760 KB Output is correct
45 Correct 85 ms 14328 KB Output is correct
46 Correct 83 ms 9464 KB Output is correct
47 Correct 119 ms 45856 KB Output is correct
48 Correct 78 ms 2396 KB Output is correct
49 Correct 79 ms 2424 KB Output is correct
50 Correct 76 ms 2188 KB Output is correct
51 Correct 143 ms 96760 KB Output is correct
52 Correct 157 ms 112672 KB Output is correct
53 Runtime error 302 ms 241136 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Halted 0 ms 0 KB -