답안 #996013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996013 2024-06-10T07:19:32 Z thdh__ Xylophone (JOI18_xylophone) C++17
100 / 100
67 ms 1104 KB
#include <bits/stdc++.h>
#include "xylophone.h"
#define ll long long
#define pb push_back
#define pu push
#define ins insert
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff(x,a,b,c) for (auto x=a;x<=b;x+=c)
#define fd(x,a,b,c) for (auto x=a;x>=b;x-=c)

using namespace std;

const int N = 1e4+5;
const int mod = 1e9+7;
int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;} 

int a[N];
int check[N];
int ans[N];

void solve(int n)
{
	a[2] = query(1,2); check[2] = 0;
	for (int i=3;i<=n;i++)
	{
		int x = query(i-1,i),y = query(i-2,i);
		a[i] = x;
		if (a[i-1]+a[i]==y) check[i] = check[i-1];
		else check[i] = 1-check[i-1];
	}
	for (int i=1;i<=n;i++) ans[i] = ans[i-1]+a[i]*(1-check[i]*2);
	int mx = INT_MIN,mn = INT_MAX,idx1,idx2;
	for (int i=1;i<=n;i++)
	{
		if (mx<ans[i]) mx = ans[i],idx1 = i;
		if (mn>ans[i]) mn = ans[i],idx2 = i;
	}
	int tmp = mn;
	if (idx1<idx2) 
	{
		for (int i=1;i<=n;i++) ans[i] = ans[i-1]+a[i]*(check[i]*2-1);
		tmp = -mx;
	}
	for (int i=1;i<=n;i++) answer(i,ans[i]-tmp+1);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:39:2: warning: 'idx2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |  if (idx1<idx2)
      |  ^~
xylophone.cpp:39:2: warning: 'idx1' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 600 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 8 ms 460 KB Output is correct
19 Correct 9 ms 456 KB Output is correct
20 Correct 13 ms 600 KB Output is correct
21 Correct 16 ms 600 KB Output is correct
22 Correct 11 ms 600 KB Output is correct
23 Correct 10 ms 592 KB Output is correct
24 Correct 9 ms 344 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 9 ms 452 KB Output is correct
28 Correct 9 ms 344 KB Output is correct
29 Correct 9 ms 452 KB Output is correct
30 Correct 9 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 600 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 8 ms 460 KB Output is correct
19 Correct 9 ms 456 KB Output is correct
20 Correct 13 ms 600 KB Output is correct
21 Correct 16 ms 600 KB Output is correct
22 Correct 11 ms 600 KB Output is correct
23 Correct 10 ms 592 KB Output is correct
24 Correct 9 ms 344 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 9 ms 452 KB Output is correct
28 Correct 9 ms 344 KB Output is correct
29 Correct 9 ms 452 KB Output is correct
30 Correct 9 ms 340 KB Output is correct
31 Correct 18 ms 600 KB Output is correct
32 Correct 35 ms 704 KB Output is correct
33 Correct 41 ms 340 KB Output is correct
34 Correct 48 ms 592 KB Output is correct
35 Correct 44 ms 956 KB Output is correct
36 Correct 52 ms 700 KB Output is correct
37 Correct 62 ms 704 KB Output is correct
38 Correct 54 ms 708 KB Output is correct
39 Correct 51 ms 344 KB Output is correct
40 Correct 59 ms 456 KB Output is correct
41 Correct 46 ms 1104 KB Output is correct
42 Correct 53 ms 592 KB Output is correct
43 Correct 60 ms 700 KB Output is correct
44 Correct 48 ms 696 KB Output is correct
45 Correct 64 ms 600 KB Output is correct
46 Correct 56 ms 452 KB Output is correct
47 Correct 67 ms 444 KB Output is correct
48 Correct 47 ms 444 KB Output is correct
49 Correct 67 ms 848 KB Output is correct
50 Correct 52 ms 344 KB Output is correct
51 Correct 48 ms 344 KB Output is correct
52 Correct 41 ms 456 KB Output is correct
53 Correct 55 ms 448 KB Output is correct
54 Correct 57 ms 468 KB Output is correct
55 Correct 67 ms 440 KB Output is correct
56 Correct 41 ms 464 KB Output is correct
57 Correct 45 ms 344 KB Output is correct
58 Correct 48 ms 716 KB Output is correct
59 Correct 51 ms 600 KB Output is correct
60 Correct 59 ms 712 KB Output is correct