Submission #722036

# Submission time Handle Problem Language Result Execution time Memory
722036 2023-04-11T10:46:58 Z PoPularPlusPlus Brunhilda’s Birthday (BOI13_brunhilda) C++17
0 / 100
250 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007; 
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

bool remender(ll a , ll b){return a%b;}

//freopen("problemname.in", "r", stdin);
//freopen("problemname.out", "w", stdout);

const int N = 10000002;
int ans[N];
vector<int> v[N];

void solve(){
	int n , qu;
	cin >> n >> qu;
	int arr[n];
	for(int i = 0; i < n; i++)cin >> arr[i];
	int mx = 0;
	for(int i = 0; i < n; i++)mx = max(mx , arr[i]);
	for(int i = 0; i < n; i++){
		for(int j = arr[i]; j <= N-2; j+=arr[i]){
			v[j].pb(i);
		}
	}
	int cur[n];
	queue<pair<int,int>> q;
	for(int i = 0; i < n; i++){
		cur[i] = 0;
		q.push(mp(0,i));
	}
	ans[0] = 0;
	for(int i = 1; i <= N-2; i++){
		ans[i] = 1e9;
		for(int j : v[i]){
			q.push(mp(i,j));
			cur[j] = i;
		}
		while(q.size()){
			pair<int,int> p = q.front();
			if(cur[p.vs] == p.vf)break;
			q.pop();
		}
		ans[i] = ans[q.front().vf]+1;
	}
	while(qu--){
		int x;
		cin >> x;
		if(ans[x] >= 1e9)cout << "oo\n";
		else cout << ans[x] << '\n';
	}
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   // int t;cin>>t;
   // while(t--){
		solve();
	//}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 150 ms 262144 KB Execution killed with signal 9
2 Runtime error 125 ms 262144 KB Execution killed with signal 9
3 Runtime error 125 ms 262144 KB Execution killed with signal 9
4 Runtime error 216 ms 262144 KB Execution killed with signal 9
5 Runtime error 123 ms 262144 KB Execution killed with signal 9
6 Runtime error 152 ms 262144 KB Execution killed with signal 9
7 Runtime error 133 ms 262144 KB Execution killed with signal 9
8 Runtime error 130 ms 262144 KB Execution killed with signal 9
9 Runtime error 135 ms 262144 KB Execution killed with signal 9
10 Runtime error 134 ms 262144 KB Execution killed with signal 9
11 Runtime error 131 ms 262144 KB Execution killed with signal 9
12 Runtime error 207 ms 262144 KB Execution killed with signal 9
13 Runtime error 157 ms 262144 KB Execution killed with signal 9
14 Runtime error 143 ms 262144 KB Execution killed with signal 9
15 Runtime error 121 ms 262144 KB Execution killed with signal 9
16 Runtime error 124 ms 262144 KB Execution killed with signal 9
17 Runtime error 174 ms 262144 KB Execution killed with signal 9
18 Runtime error 220 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 212 ms 262144 KB Execution killed with signal 9
2 Runtime error 173 ms 262144 KB Execution killed with signal 9
3 Runtime error 141 ms 262144 KB Execution killed with signal 9
4 Runtime error 121 ms 262144 KB Execution killed with signal 9
5 Runtime error 137 ms 262144 KB Execution killed with signal 9
6 Runtime error 128 ms 262144 KB Execution killed with signal 9
7 Runtime error 197 ms 262144 KB Execution killed with signal 9
8 Runtime error 135 ms 262144 KB Execution killed with signal 9
9 Runtime error 148 ms 262144 KB Execution killed with signal 9
10 Runtime error 128 ms 262144 KB Execution killed with signal 9
11 Runtime error 122 ms 262144 KB Execution killed with signal 9
12 Runtime error 138 ms 262144 KB Execution killed with signal 9
13 Runtime error 134 ms 262144 KB Execution killed with signal 9
14 Runtime error 129 ms 262144 KB Execution killed with signal 9
15 Runtime error 130 ms 262144 KB Execution killed with signal 9
16 Runtime error 156 ms 262144 KB Execution killed with signal 9
17 Runtime error 127 ms 262144 KB Execution killed with signal 9
18 Runtime error 144 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 162 ms 262144 KB Execution killed with signal 9
2 Runtime error 155 ms 262144 KB Execution killed with signal 9
3 Runtime error 127 ms 262144 KB Execution killed with signal 9
4 Runtime error 125 ms 262144 KB Execution killed with signal 9
5 Runtime error 250 ms 262144 KB Execution killed with signal 9
6 Runtime error 131 ms 262144 KB Execution killed with signal 9
7 Runtime error 139 ms 262144 KB Execution killed with signal 9
8 Runtime error 138 ms 262144 KB Execution killed with signal 9
9 Runtime error 137 ms 262144 KB Execution killed with signal 9
10 Runtime error 124 ms 262144 KB Execution killed with signal 9
11 Runtime error 152 ms 262144 KB Execution killed with signal 9
12 Runtime error 132 ms 262144 KB Execution killed with signal 9
13 Runtime error 122 ms 262144 KB Execution killed with signal 9
14 Runtime error 123 ms 262144 KB Execution killed with signal 9
15 Runtime error 140 ms 262144 KB Execution killed with signal 9
16 Runtime error 125 ms 262144 KB Execution killed with signal 9
17 Runtime error 127 ms 262144 KB Execution killed with signal 9
18 Runtime error 151 ms 262144 KB Execution killed with signal 9
19 Runtime error 126 ms 262144 KB Execution killed with signal 9
20 Runtime error 126 ms 262144 KB Execution killed with signal 9
21 Runtime error 132 ms 262144 KB Execution killed with signal 9
22 Runtime error 158 ms 262144 KB Execution killed with signal 9
23 Runtime error 228 ms 262144 KB Execution killed with signal 9
24 Runtime error 170 ms 262144 KB Execution killed with signal 9
25 Runtime error 135 ms 262144 KB Execution killed with signal 9
26 Runtime error 119 ms 262144 KB Execution killed with signal 9
27 Runtime error 147 ms 262144 KB Execution killed with signal 9
28 Runtime error 129 ms 262144 KB Execution killed with signal 9
29 Runtime error 140 ms 262144 KB Execution killed with signal 9
30 Runtime error 170 ms 262144 KB Execution killed with signal 9
31 Runtime error 134 ms 262144 KB Execution killed with signal 9
32 Runtime error 124 ms 262144 KB Execution killed with signal 9
33 Runtime error 158 ms 262144 KB Execution killed with signal 9
34 Runtime error 138 ms 262144 KB Execution killed with signal 9
35 Runtime error 127 ms 262144 KB Execution killed with signal 9
36 Runtime error 155 ms 262144 KB Execution killed with signal 9
37 Runtime error 226 ms 262144 KB Execution killed with signal 9
38 Runtime error 126 ms 262144 KB Execution killed with signal 9
39 Runtime error 175 ms 262144 KB Execution killed with signal 9
40 Runtime error 141 ms 262144 KB Execution killed with signal 9
41 Runtime error 156 ms 262144 KB Execution killed with signal 9
42 Runtime error 151 ms 262144 KB Execution killed with signal 9