제출 #1136208

#제출 시각아이디문제언어결과실행 시간메모리
1136208thdh__Sum Zero (RMI20_sumzero)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define eb emplace_back
#define pu push
#define ins insert
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fu(x,a,b) for (auto x=a;x<=b;x++)
#define fd(x,a,b) for (auto x=a;x>=b;x--)

using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> ii;
const int N = 4e5+5;
const int M = 19;
using cd = complex<double>;
const long double PI = acos(-1);
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 n,q;
int a[N], nxt[N], ans[N], l[N], r[N];
unordered_map<int,int> p;

void solve()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	p[0] = n+1;
	nxt[n+1] = n+2;
	nxt[n+2] = n+2;
	int sum = 0;
	for (int i=n;i>=1;i--) 
	{
		sum += a[i];
		if (p.find(sum) == p.end()) nxt[i] = nxt[i+1];
		else nxt[i] = min(nxt[i+1], p[sum]);
		p[sum] = i;
	}
	cin>>q;
	for (int i=0;i<q;i++) cin>>l[i]>>r[i];
	for (int i=M-1;i>=0;i--) 
	{
		for (int j=1;j<=n+2;j++) a[j] = nxt[j];
		for (int j=1;j<=i;j++) 
		{
			for (int k=1;k<=n+2;k++) a[k] = a[a[k]];
		} 
		for (int j=0;j<q;j++) if (a[l[j]] <= r[j]+1) l[j] = a[l[j]], ans[j] += (1<<i);
	}
	for (int i=0;i<q;i++) cout<<ans[i]<<endl;
}

signed main()
{
	bruh
	//freopen("input.inp","r",stdin);
	//freopen("output.inp","w",stdout);
	int t = 1;
	// cin>>t;
	while (t--)
	{
		solve();
		cout<<"\n";
	}
}

컴파일 시 표준 에러 (stderr) 메시지

sumzero.cpp: In function 'int power(int, int)':
sumzero.cpp:24:43: error: 'mod' was not declared in this scope; did you mean 'modf'?
   24 | 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;}
      |                                           ^~~
      |                                           modf
sumzero.cpp:24:88: error: 'mod' was not declared in this scope; did you mean 'modf'?
   24 | 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;}
      |                                                                                        ^~~
      |                                                                                        modf
sumzero.cpp:24:102: error: 'mod' was not declared in this scope; did you mean 'modf'?
   24 | 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;}
      |                                                                                                      ^~~
      |                                                                                                      modf