Submission #923091

# Submission time Handle Problem Language Result Execution time Memory
923091 2024-02-06T14:52:44 Z 8pete8 Brunhilda’s Birthday (BOI13_brunhilda) C++17
40 / 100
1000 ms 2908 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<cassert>
#include<limits.h>
#include<cmath>
#include<set>
#include<numeric> //gcd(a,b)
#include<algorithm>
#include<bitset> 
#include<stack>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define pppiiii pair<pii,pii>
#define ppii pair<int,pii>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
const int mod=998244353,mxn=1e6+5,lg=30,inf=1e18,minf=-1e18,Mxn=100000,root=700;
void setIO(string name){		
	ios_base::sync_with_stdio(0); cin.tie(0);		
	freopen((name+".in").c_str(),"r",stdin);		
	freopen((name+".out").c_str(),"w",stdout);	
}	
int n,q;
vector<int>v;
void solve(){
	int ans=0;
	int cur;cin>>cur;
	vector<int>op(n);
	while(cur){
		int lc=cur;
		ans++;
		for(int i=0;i<n;i++)op[i]=(cur/v[i])*v[i];
		for(auto i:op)cur=min(cur,i);
		if(lc==cur){
			cout<<"oo\n";
			return;
		}
	}
	cout<<ans<<'\n';
}
int32_t main(){
	fastio
	cin>>n>>q;//brute force
	v.resize(n);
	for(int i=0;i<n;i++)cin>>v[i];
	while(q--)solve();
}

Compilation message

brunhilda.cpp: In function 'void setIO(std::string)':
brunhilda.cpp:36:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 8 ms 476 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 360 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 10 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 6 ms 348 KB Output is correct
14 Correct 51 ms 512 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 32 ms 348 KB Output is correct
18 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 8 ms 2396 KB Output is correct
3 Correct 6 ms 1884 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 5 ms 1624 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 1884 KB Output is correct
10 Correct 6 ms 1884 KB Output is correct
11 Correct 7 ms 1116 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 4 ms 1244 KB Output is correct
16 Correct 8 ms 2576 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 13 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 1744 KB Time limit exceeded
2 Execution timed out 1061 ms 1728 KB Time limit exceeded
3 Execution timed out 1032 ms 1744 KB Time limit exceeded
4 Execution timed out 1018 ms 596 KB Time limit exceeded
5 Execution timed out 1049 ms 2652 KB Time limit exceeded
6 Execution timed out 1037 ms 604 KB Time limit exceeded
7 Execution timed out 1049 ms 2908 KB Time limit exceeded
8 Execution timed out 1025 ms 1624 KB Time limit exceeded
9 Execution timed out 1047 ms 1884 KB Time limit exceeded
10 Execution timed out 1064 ms 604 KB Time limit exceeded
11 Execution timed out 1054 ms 616 KB Time limit exceeded
12 Execution timed out 1039 ms 600 KB Time limit exceeded
13 Execution timed out 1014 ms 1132 KB Time limit exceeded
14 Execution timed out 1037 ms 344 KB Time limit exceeded
15 Execution timed out 1030 ms 600 KB Time limit exceeded
16 Execution timed out 1045 ms 600 KB Time limit exceeded
17 Execution timed out 1047 ms 1528 KB Time limit exceeded
18 Execution timed out 1069 ms 1728 KB Time limit exceeded
19 Execution timed out 1037 ms 624 KB Time limit exceeded
20 Execution timed out 1044 ms 1744 KB Time limit exceeded
21 Execution timed out 1052 ms 348 KB Time limit exceeded
22 Execution timed out 1022 ms 2904 KB Time limit exceeded
23 Execution timed out 1053 ms 1136 KB Time limit exceeded
24 Execution timed out 1059 ms 564 KB Time limit exceeded
25 Execution timed out 1061 ms 604 KB Time limit exceeded
26 Execution timed out 1020 ms 600 KB Time limit exceeded
27 Execution timed out 1029 ms 2908 KB Time limit exceeded
28 Execution timed out 1069 ms 596 KB Time limit exceeded
29 Execution timed out 1041 ms 2908 KB Time limit exceeded
30 Execution timed out 1032 ms 2132 KB Time limit exceeded
31 Execution timed out 1052 ms 612 KB Time limit exceeded
32 Execution timed out 1018 ms 600 KB Time limit exceeded
33 Execution timed out 1065 ms 756 KB Time limit exceeded
34 Execution timed out 1025 ms 2904 KB Time limit exceeded
35 Execution timed out 1057 ms 576 KB Time limit exceeded
36 Execution timed out 1062 ms 2700 KB Time limit exceeded
37 Execution timed out 1034 ms 2648 KB Time limit exceeded
38 Execution timed out 1040 ms 600 KB Time limit exceeded
39 Execution timed out 1053 ms 348 KB Time limit exceeded
40 Execution timed out 1060 ms 820 KB Time limit exceeded
41 Execution timed out 1048 ms 2908 KB Time limit exceeded
42 Execution timed out 1020 ms 600 KB Time limit exceeded