Submission #150881

# Submission time Handle Problem Language Result Execution time Memory
150881 2019-09-01T09:52:26 Z cheetose Brunhilda’s Birthday (BOI13_brunhilda) C++11
100 / 100
831 ms 235876 KB
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int d[20000003],mx[20000003],to[20000003];
int a[100000];
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	fup(i,0,n-1,1)scanf("%d",a+i);
	fup(i,0,n-1,1)
	{
		fup(j,a[i],20000001,a[i])mx[j]=a[i];
	}
	int mn=20000000;
	fdn(i,20000000,1,1)
	{
		mn=min(mn,i+1-mx[i+1]);
		to[i]=mn;
	}
	fup(i,1,20000000,1)
	{
		if(to[i]==i)d[i]=INF;
		else d[i]=d[to[i]]+1;
	}
	while(q--)
	{
		int x;
		scanf("%d",&x);
		int ans=d[x];
		if(ans>=INF)puts("oo");
		else printf("%d\n",ans);
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:67:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&q);
  ~~~~~^~~~~~~~~~~~~~
brunhilda.cpp:68:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fup(i,0,n-1,1)scanf("%d",a+i);
                ~~~~~^~~~~~~~~~
brunhilda.cpp:87:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 247 ms 235084 KB Output is correct
2 Correct 291 ms 235256 KB Output is correct
3 Correct 260 ms 235104 KB Output is correct
4 Correct 236 ms 235160 KB Output is correct
5 Correct 267 ms 235072 KB Output is correct
6 Correct 234 ms 235256 KB Output is correct
7 Correct 256 ms 235208 KB Output is correct
8 Correct 278 ms 235280 KB Output is correct
9 Correct 313 ms 235256 KB Output is correct
10 Correct 362 ms 235252 KB Output is correct
11 Correct 347 ms 235296 KB Output is correct
12 Correct 231 ms 235100 KB Output is correct
13 Correct 612 ms 235196 KB Output is correct
14 Correct 615 ms 235208 KB Output is correct
15 Correct 321 ms 235164 KB Output is correct
16 Correct 292 ms 235192 KB Output is correct
17 Correct 303 ms 235216 KB Output is correct
18 Correct 238 ms 235100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 278 ms 235156 KB Output is correct
2 Correct 308 ms 235484 KB Output is correct
3 Correct 765 ms 235444 KB Output is correct
4 Correct 344 ms 235240 KB Output is correct
5 Correct 528 ms 235384 KB Output is correct
6 Correct 288 ms 235256 KB Output is correct
7 Correct 274 ms 235256 KB Output is correct
8 Correct 329 ms 235256 KB Output is correct
9 Correct 617 ms 235472 KB Output is correct
10 Correct 760 ms 235468 KB Output is correct
11 Correct 746 ms 235352 KB Output is correct
12 Correct 424 ms 235256 KB Output is correct
13 Correct 251 ms 235152 KB Output is correct
14 Correct 344 ms 235116 KB Output is correct
15 Correct 610 ms 235308 KB Output is correct
16 Correct 304 ms 235548 KB Output is correct
17 Correct 656 ms 235208 KB Output is correct
18 Correct 617 ms 235588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 629 ms 235532 KB Output is correct
2 Correct 766 ms 235400 KB Output is correct
3 Correct 773 ms 235460 KB Output is correct
4 Correct 475 ms 235540 KB Output is correct
5 Correct 374 ms 235816 KB Output is correct
6 Correct 637 ms 235352 KB Output is correct
7 Correct 568 ms 235716 KB Output is correct
8 Correct 616 ms 235404 KB Output is correct
9 Correct 622 ms 235424 KB Output is correct
10 Correct 518 ms 235216 KB Output is correct
11 Correct 442 ms 235212 KB Output is correct
12 Correct 593 ms 235284 KB Output is correct
13 Correct 748 ms 235564 KB Output is correct
14 Correct 417 ms 235768 KB Output is correct
15 Correct 600 ms 235364 KB Output is correct
16 Correct 695 ms 235248 KB Output is correct
17 Correct 605 ms 235360 KB Output is correct
18 Correct 770 ms 235512 KB Output is correct
19 Correct 272 ms 235228 KB Output is correct
20 Correct 810 ms 235516 KB Output is correct
21 Correct 482 ms 235708 KB Output is correct
22 Correct 780 ms 235844 KB Output is correct
23 Correct 367 ms 235588 KB Output is correct
24 Correct 296 ms 235416 KB Output is correct
25 Correct 521 ms 235512 KB Output is correct
26 Correct 464 ms 235364 KB Output is correct
27 Correct 831 ms 235844 KB Output is correct
28 Correct 298 ms 235512 KB Output is correct
29 Correct 745 ms 235768 KB Output is correct
30 Correct 686 ms 235656 KB Output is correct
31 Correct 362 ms 235564 KB Output is correct
32 Correct 384 ms 235512 KB Output is correct
33 Correct 268 ms 235384 KB Output is correct
34 Correct 566 ms 235592 KB Output is correct
35 Correct 324 ms 235400 KB Output is correct
36 Correct 745 ms 235744 KB Output is correct
37 Correct 356 ms 235876 KB Output is correct
38 Correct 634 ms 235556 KB Output is correct
39 Correct 324 ms 235480 KB Output is correct
40 Correct 536 ms 235512 KB Output is correct
41 Correct 482 ms 235584 KB Output is correct
42 Correct 692 ms 235640 KB Output is correct