Submission #206896

# Submission time Handle Problem Language Result Execution time Memory
206896 2020-03-05T18:23:55 Z MvC Brunhilda’s Birthday (BOI13_brunhilda) C++11
17.7778 / 100
13 ms 2040 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e4+50;
const int mod=1e9+7;
using namespace std;
int n,q,f[nmax],pr[nmax],x,i,j;
bitset<nmax>viz;
set<pair<int,int> >s;
set<pair<int,int> >::iterator it;
vector<int>d[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>q;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		for(j=x;j<=1e4;j+=x)d[j].pb(x);
		s.in(mkp(pr[x],x));
	}
	for(i=1;i<=1e4;i++)
	{
		f[i]=inf;
		for(j=0;j<(int)d[i].size();j++)viz[d[i][j]]=1;
		for(it=s.begin();it!=s.end();it++)
		{
			if(viz[it->sc])continue;
			f[i]=it->fr+1;
			break;
		}
		for(j=0;j<(int)d[i].size();j++)
		{
			viz[d[i][j]]=0;
			s.er(s.fd(mkp(pr[d[i][j]],d[i][j])));
			pr[d[i][j]]=f[i];
			s.in(mkp(pr[d[i][j]],d[i][j]));
		}
	}
	while(q--)
	{
		cin>>x;
		if(f[x]==inf)cout<<"oo\n";
		else cout<<f[x]<<'\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 636 KB Output isn't correct
2 Correct 7 ms 888 KB Output is correct
3 Correct 6 ms 760 KB Output is correct
4 Correct 7 ms 760 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Incorrect 5 ms 628 KB Output isn't correct
7 Correct 6 ms 760 KB Output is correct
8 Correct 7 ms 888 KB Output is correct
9 Correct 8 ms 888 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 8 ms 764 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 12 ms 1016 KB Output is correct
14 Correct 13 ms 1016 KB Output is correct
15 Correct 7 ms 892 KB Output is correct
16 Correct 7 ms 888 KB Output is correct
17 Correct 8 ms 760 KB Output is correct
18 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 6 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 7 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 6 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 6 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 8 ms 1916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 6 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 6 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 8 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 8 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 7 ms 1780 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 10 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 7 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 8 ms 1788 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 7 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 7 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 6 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 8 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 10 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 8 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 7 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 7 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 11 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 6 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 7 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 7 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 8 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 6 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 6 ms 1276 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 6 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 6 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 7 ms 1580 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 6 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 8 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 7 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 8 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)