Submission #134267

# Submission time Handle Problem Language Result Execution time Memory
134267 2019-07-22T10:16:40 Z claudy Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
340 ms 91896 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[30005];
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 <= 10 * n;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")
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1148 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1080 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1188 KB Output is correct
9 Correct 3 ms 1272 KB Output is correct
10 Correct 5 ms 1400 KB Output is correct
11 Correct 5 ms 1400 KB Output is correct
12 Correct 5 ms 1912 KB Output is correct
13 Correct 5 ms 1784 KB Output is correct
14 Correct 5 ms 1528 KB Output is correct
15 Correct 5 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 4 ms 1400 KB Output is correct
10 Correct 4 ms 1444 KB Output is correct
11 Correct 5 ms 1532 KB Output is correct
12 Correct 5 ms 1912 KB Output is correct
13 Correct 5 ms 1784 KB Output is correct
14 Correct 5 ms 1528 KB Output is correct
15 Correct 5 ms 1404 KB Output is correct
16 Correct 10 ms 1148 KB Output is correct
17 Correct 15 ms 3704 KB Output is correct
18 Correct 27 ms 1272 KB Output is correct
19 Correct 30 ms 1272 KB Output is correct
20 Correct 69 ms 16008 KB Output is correct
21 Correct 8 ms 1144 KB Output is correct
22 Correct 27 ms 1232 KB Output is correct
23 Correct 26 ms 4348 KB Output is correct
24 Correct 31 ms 4472 KB Output is correct
25 Correct 37 ms 15992 KB Output is correct
26 Correct 54 ms 19192 KB Output is correct
27 Correct 43 ms 19376 KB Output is correct
28 Correct 62 ms 73720 KB Output is correct
29 Correct 36 ms 13612 KB Output is correct
30 Correct 35 ms 11768 KB Output is correct
31 Correct 39 ms 12920 KB Output is correct
32 Correct 40 ms 15736 KB Output is correct
33 Correct 40 ms 13560 KB Output is correct
34 Correct 35 ms 8696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1272 KB Output is correct
10 Correct 5 ms 1528 KB Output is correct
11 Correct 5 ms 1528 KB Output is correct
12 Correct 6 ms 1912 KB Output is correct
13 Correct 6 ms 1912 KB Output is correct
14 Correct 5 ms 1528 KB Output is correct
15 Correct 5 ms 1528 KB Output is correct
16 Correct 6 ms 1144 KB Output is correct
17 Correct 15 ms 3704 KB Output is correct
18 Correct 27 ms 1272 KB Output is correct
19 Correct 32 ms 1272 KB Output is correct
20 Correct 75 ms 15992 KB Output is correct
21 Correct 9 ms 1144 KB Output is correct
22 Correct 27 ms 1272 KB Output is correct
23 Correct 28 ms 4344 KB Output is correct
24 Correct 31 ms 4472 KB Output is correct
25 Correct 38 ms 15992 KB Output is correct
26 Correct 54 ms 19192 KB Output is correct
27 Correct 50 ms 19448 KB Output is correct
28 Correct 62 ms 73720 KB Output is correct
29 Correct 36 ms 13688 KB Output is correct
30 Correct 35 ms 11768 KB Output is correct
31 Correct 36 ms 12920 KB Output is correct
32 Correct 37 ms 15748 KB Output is correct
33 Correct 38 ms 13688 KB Output is correct
34 Correct 36 ms 8696 KB Output is correct
35 Correct 33 ms 6748 KB Output is correct
36 Correct 21 ms 4088 KB Output is correct
37 Correct 40 ms 8628 KB Output is correct
38 Correct 47 ms 9208 KB Output is correct
39 Correct 47 ms 9208 KB Output is correct
40 Correct 44 ms 9208 KB Output is correct
41 Correct 45 ms 9336 KB Output is correct
42 Correct 296 ms 19832 KB Output is correct
43 Correct 241 ms 20012 KB Output is correct
44 Correct 340 ms 16540 KB Output is correct
45 Correct 44 ms 14168 KB Output is correct
46 Correct 42 ms 9208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1016 KB Output is correct
5 Correct 3 ms 1148 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 4 ms 1400 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 5 ms 1528 KB Output is correct
12 Correct 5 ms 1912 KB Output is correct
13 Correct 5 ms 1784 KB Output is correct
14 Correct 5 ms 1528 KB Output is correct
15 Correct 5 ms 1532 KB Output is correct
16 Correct 6 ms 1144 KB Output is correct
17 Correct 15 ms 3704 KB Output is correct
18 Correct 27 ms 1272 KB Output is correct
19 Correct 30 ms 1272 KB Output is correct
20 Correct 76 ms 15992 KB Output is correct
21 Correct 9 ms 1144 KB Output is correct
22 Correct 27 ms 1272 KB Output is correct
23 Correct 26 ms 4344 KB Output is correct
24 Correct 31 ms 4472 KB Output is correct
25 Correct 38 ms 15996 KB Output is correct
26 Correct 55 ms 19212 KB Output is correct
27 Correct 50 ms 19356 KB Output is correct
28 Correct 62 ms 73720 KB Output is correct
29 Correct 36 ms 13688 KB Output is correct
30 Correct 36 ms 11768 KB Output is correct
31 Correct 36 ms 12920 KB Output is correct
32 Correct 37 ms 15708 KB Output is correct
33 Correct 37 ms 13560 KB Output is correct
34 Correct 35 ms 8696 KB Output is correct
35 Correct 33 ms 6776 KB Output is correct
36 Correct 21 ms 4088 KB Output is correct
37 Correct 40 ms 8572 KB Output is correct
38 Correct 44 ms 9208 KB Output is correct
39 Correct 44 ms 9208 KB Output is correct
40 Correct 43 ms 9240 KB Output is correct
41 Correct 44 ms 9228 KB Output is correct
42 Correct 296 ms 19884 KB Output is correct
43 Correct 240 ms 20088 KB Output is correct
44 Correct 329 ms 16468 KB Output is correct
45 Correct 44 ms 14072 KB Output is correct
46 Correct 42 ms 9208 KB Output is correct
47 Runtime error 156 ms 91896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Halted 0 ms 0 KB -