Submission #168851

# Submission time Handle Problem Language Result Execution time Memory
168851 2019-12-16T16:54:53 Z kostia244 Toys (CEOI18_toy) C++17
0 / 100
230 ms 262148 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,sse2,sse,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC comment("/STACK:26666666")
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int mod = 1e9 + 7;
ll n;
vi divs, cans[100100], canb[100100];
int id[100100];
const int C = 923107;
const int B = 923917;
bitset<C> *vis;
bitset<B> *vis2;
__attribute__((always_inline)) inline bool mark(ll i, ll cur) {
	ll x = (i*i <= n ? id[i] : id[31628+(n/i)]);
	ll z = (13ll*cur + 13)%C;
	ll zz = (127ll*cur + 31)%B;
	if(vis[x][z]&&vis2[x][zz]) return false;
	vis[x][z] = 1;
	vis2[x][zz] = 1;
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	vis =new bitset<C>[1345];
	vis2 =new bitset<B>[1345];
	cin >> n;
	ll tn = n;
	int x = 0;
	for (ll d = 1; d * d <= tn; d++) {
		if (tn % d)
			continue;
		divs.pb(d);
		id[d] = x++;
		if (d * d != n) {
			id[31628+d]=x++;
			divs.pb(n / d);
		}
	}
	sort(all(divs));
	cans[1].pb(0);
	for (auto i : divs) {
		vi &t = (i * i <= n ? cans[i] : canb[n / i]);
		sort(all(t));
		t.erase(unique(all(t)), t.end());
		for (auto j : divs) {
			if(j==1)continue;
			if (i * j > n)
				break;
			if (n % (i * j))
				continue;
			ll _nxt = i * j;
			vi &nxt = (_nxt * _nxt <= n ? cans[_nxt] : canb[n / _nxt]);
			for (auto q : t) {
				if(mark(_nxt, q+j-1))
				nxt.pb(q + j - 1);
			}
		}
	}
	vi &t = (n * n <= n ? cans[n] : canb[n / n]);
	sort(all(t));
	cout << t.size() << "\n";
//	for (auto i : t)
//		cout << i << " ";
}

Compilation message

toy.cpp:4:0: warning: ignoring #pragma GCC comment [-Wunknown-pragmas]
 #pragma GCC comment("/STACK:26666666")
# Verdict Execution time Memory Grader output
1 Runtime error 230 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 230 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 230 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 230 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 230 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -