Submission #946156

# Submission time Handle Problem Language Result Execution time Memory
946156 2024-03-14T11:11:28 Z firewater Chorus (JOI23_chorus) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ask(int k)
{
	for(int i=1;i<=n;++i)
		f[i]=1000000000,s[i]=0;
	for(int i=1;i<=n;++i)
		for(int j=0;j<i;++j)
			if({f[j]+sum[i]-sum[v[j+1]]+j*(i-v[j+1])+k,s[j]+1}<{f[i],s[i]}){
				f[i]=f[j]+sum[i]-sum[v[j+1]]+j*(i-v[j+1])+k;
				s[i]=s[j]+1;
			}
	return s[n];
}
int main()
{
	scanf("%d%d%s",&n,&k,s+1);
	x=now=0;
	for(int i=1;i<=n*2;++i){
		if(i=='A'){
			a[++x]=now;
			sum[x]=sum[x-1]+a[x];
		}
		else v[++now]=x;
	}
	l=0;
	r=1000000000000ll;
	while(l<r){
		ll mid=l+r>>1;
		if(ask(mid)<=k)r=mid;
		else r=mid-1;
	}
}

Compilation message

chorus.cpp: In function 'int ask(int)':
chorus.cpp:6:17: error: 'n' was not declared in this scope
    6 |  for(int i=1;i<=n;++i)
      |                 ^
chorus.cpp:7:3: error: 'f' was not declared in this scope
    7 |   f[i]=1000000000,s[i]=0;
      |   ^
chorus.cpp:7:19: error: 's' was not declared in this scope
    7 |   f[i]=1000000000,s[i]=0;
      |                   ^
chorus.cpp:8:17: error: 'n' was not declared in this scope
    8 |  for(int i=1;i<=n;++i)
      |                 ^
chorus.cpp:10:7: error: expected primary-expression before '{' token
   10 |    if({f[j]+sum[i]-sum[v[j+1]]+j*(i-v[j+1])+k,s[j]+1}<{f[i],s[i]}){
      |       ^
chorus.cpp:10:7: error: expected ')' before '{' token
   10 |    if({f[j]+sum[i]-sum[v[j+1]]+j*(i-v[j+1])+k,s[j]+1}<{f[i],s[i]}){
      |      ~^
      |       )
chorus.cpp:11:5: error: 'f' was not declared in this scope
   11 |     f[i]=f[j]+sum[i]-sum[v[j+1]]+j*(i-v[j+1])+k;
      |     ^
chorus.cpp:11:15: error: 'sum' was not declared in this scope
   11 |     f[i]=f[j]+sum[i]-sum[v[j+1]]+j*(i-v[j+1])+k;
      |               ^~~
chorus.cpp:11:26: error: 'v' was not declared in this scope
   11 |     f[i]=f[j]+sum[i]-sum[v[j+1]]+j*(i-v[j+1])+k;
      |                          ^
chorus.cpp:12:5: error: 's' was not declared in this scope
   12 |     s[i]=s[j]+1;
      |     ^
chorus.cpp:14:9: error: 's' was not declared in this scope
   14 |  return s[n];
      |         ^
chorus.cpp:14:11: error: 'n' was not declared in this scope
   14 |  return s[n];
      |           ^
chorus.cpp: In function 'int main()':
chorus.cpp:18:18: error: 'n' was not declared in this scope; did you mean 'yn'?
   18 |  scanf("%d%d%s",&n,&k,s+1);
      |                  ^
      |                  yn
chorus.cpp:18:21: error: 'k' was not declared in this scope
   18 |  scanf("%d%d%s",&n,&k,s+1);
      |                     ^
chorus.cpp:18:23: error: 's' was not declared in this scope
   18 |  scanf("%d%d%s",&n,&k,s+1);
      |                       ^
chorus.cpp:19:2: error: 'x' was not declared in this scope
   19 |  x=now=0;
      |  ^
chorus.cpp:19:4: error: 'now' was not declared in this scope; did you mean 'pow'?
   19 |  x=now=0;
      |    ^~~
      |    pow
chorus.cpp:22:4: error: 'a' was not declared in this scope
   22 |    a[++x]=now;
      |    ^
chorus.cpp:23:4: error: 'sum' was not declared in this scope
   23 |    sum[x]=sum[x-1]+a[x];
      |    ^~~
chorus.cpp:25:8: error: 'v' was not declared in this scope
   25 |   else v[++now]=x;
      |        ^
chorus.cpp:27:2: error: 'l' was not declared in this scope; did you mean 'll'?
   27 |  l=0;
      |  ^
      |  ll
chorus.cpp:28:2: error: 'r' was not declared in this scope
   28 |  r=1000000000000ll;
      |  ^