답안 #206895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206895 2020-03-05T18:21:24 Z MvC Brunhilda’s Birthday (BOI13_brunhilda) C++11
0 / 100
325 ms 262148 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=1e7+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<=1e7;j+=x)d[j].pb(x);
		s.in(mkp(pr[x],x));
	}
	for(i=1;i<=1e7;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;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 205 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 169 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 172 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 281 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 175 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 187 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 182 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 167 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 172 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 172 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 192 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 298 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 176 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 171 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 165 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 172 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 270 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 281 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 203 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 178 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 176 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 166 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 187 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 273 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 182 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 169 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 174 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 170 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 179 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 181 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 192 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 181 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 202 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 164 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 167 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 182 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 179 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 177 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 194 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 305 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 185 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 192 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 168 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 177 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 186 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 165 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 179 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 171 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 171 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 168 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 170 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 178 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 173 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 174 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 189 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 172 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 167 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 325 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 194 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 177 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 169 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 172 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 169 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 184 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 182 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Runtime error 180 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
32 Runtime error 163 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
33 Runtime error 220 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
34 Runtime error 185 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
35 Runtime error 180 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
36 Runtime error 166 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
37 Runtime error 294 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
38 Runtime error 168 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Runtime error 198 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Runtime error 173 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Runtime error 173 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Runtime error 166 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)