Submission #1290630

#TimeUsernameProblemLanguageResultExecution timeMemory
1290630amodiXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#include "xylophone.h"
#define int long long
static int A[5000];
void solve(int n) {
	vector<array,2>fark(n+1);
	fark[n-1][0]=query(n-1,n);
	for(int i=1;i<n-1;i++) {
		fark[i][0]=query(i,i+1);
		fark[i][1]=query(i,i+2);
	}
	vector<bool>cs(n+1);
	//ilk yön +
	cs[1]=1;
	int toplam=0;
	int mx=0;
	int mn=0;
	int mxi=1;
	int mni=1;
	for(int i=1;i<n-1;i++){
		if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
		else cs[i+1]=(!cs[i]);
	}
	for(int i=1;i<=n-1;i++){
	if(cs[i])toplam+=fark[i][0];
	else toplam +=0-fark[i][0];
	if(mx<ans){
		mx=ans;
		mxi=i+1;
	}
	if(mn<ans){
		mn=ans;
		mni=i+1
	}
}
	if(mni<mxi){
	int ansid=n-mx;
	answer(1,ansid);
    for(int i=2;i<=n;i++){
			if(!cs[i])ansid-=fark[i-1][0];
			else ansid+=fark[i-1][0];
			answer(i,ansid);
		}
		
	
}
//ilk yön -
	else{
	cs[1]=0;
	int toplam=0;
	 mx=0;
	 mn=0;
	 mxi=1;
	 mni=1;
	 toplam=0;
	for(int i=1;i<n-1;i++){
		if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
		else cs[i+1]=(!cs[i]);
	}
	for(int i=1;i<=n-1;i++){
	if(cs[i])toplam+=fark[i][0];
	else toplam +=0-fark[i][0];
	if(mx<ans){
		mx=ans;
		mxi=i+1;
	}
	if(mn<ans){
		mn=ans;
		mni=i+1
	}
}
	
	int ansid=n-mx;
	answer(1,ansid);
    for(int i=2;i<=n;i++){
			if(!cs[i])ansid-=fark[i-1][0];
			else ansid+=fark[i-1][0];
			answer(i,ansid);
		}
		
	

}
}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(long long int)':
xylophone.cpp:7:23: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
    7 |         vector<array,2>fark(n+1);
      |                       ^
xylophone.cpp:7:23: note:   expected a type, got 'array'
xylophone.cpp:7:23: error: type/value mismatch at argument 2 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
xylophone.cpp:7:23: note:   expected a type, got '2'
xylophone.cpp:8:13: error: invalid types 'int[long long int]' for array subscript
    8 |         fark[n-1][0]=query(n-1,n);
      |             ^
xylophone.cpp:10:21: error: invalid types 'int[long long int]' for array subscript
   10 |                 fark[i][0]=query(i,i+1);
      |                     ^
xylophone.cpp:11:21: error: invalid types 'int[long long int]' for array subscript
   11 |                 fark[i][1]=query(i,i+2);
      |                     ^
xylophone.cpp:22:24: error: invalid types 'int[long long int]' for array subscript
   22 |                 if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
      |                        ^
xylophone.cpp:22:36: error: invalid types 'int[long long int]' for array subscript
   22 |                 if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
      |                                    ^
xylophone.cpp:22:49: error: invalid types 'int[long long int]' for array subscript
   22 |                 if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
      |                                                 ^
xylophone.cpp:26:30: error: invalid types 'int[long long int]' for array subscript
   26 |         if(cs[i])toplam+=fark[i][0];
      |                              ^
xylophone.cpp:27:29: error: invalid types 'int[long long int]' for array subscript
   27 |         else toplam +=0-fark[i][0];
      |                             ^
xylophone.cpp:28:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |         if(mx<ans){
      |               ^~~
      |               abs
xylophone.cpp:32:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |         if(mn<ans){
      |               ^~~
      |               abs
xylophone.cpp:34:24: error: expected ';' before '}' token
   34 |                 mni=i+1
      |                        ^
      |                        ;
   35 |         }
      |         ~               
xylophone.cpp:41:46: error: invalid types 'int[long long int]' for array subscript
   41 |                         if(!cs[i])ansid-=fark[i-1][0];
      |                                              ^
xylophone.cpp:42:41: error: invalid types 'int[long long int]' for array subscript
   42 |                         else ansid+=fark[i-1][0];
      |                                         ^
xylophone.cpp:58:24: error: invalid types 'int[long long int]' for array subscript
   58 |                 if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
      |                        ^
xylophone.cpp:58:36: error: invalid types 'int[long long int]' for array subscript
   58 |                 if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
      |                                    ^
xylophone.cpp:58:49: error: invalid types 'int[long long int]' for array subscript
   58 |                 if(fark[i][1]==fark[i+1][0]+fark[i][0])cs[i+1]=cs[i];
      |                                                 ^
xylophone.cpp:62:30: error: invalid types 'int[long long int]' for array subscript
   62 |         if(cs[i])toplam+=fark[i][0];
      |                              ^
xylophone.cpp:63:29: error: invalid types 'int[long long int]' for array subscript
   63 |         else toplam +=0-fark[i][0];
      |                             ^
xylophone.cpp:64:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |         if(mx<ans){
      |               ^~~
      |               abs
xylophone.cpp:68:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   68 |         if(mn<ans){
      |               ^~~
      |               abs
xylophone.cpp:70:24: error: expected ';' before '}' token
   70 |                 mni=i+1
      |                        ^
      |                        ;
   71 |         }
      |         ~               
xylophone.cpp:77:46: error: invalid types 'int[long long int]' for array subscript
   77 |                         if(!cs[i])ansid-=fark[i-1][0];
      |                                              ^
xylophone.cpp:78:41: error: invalid types 'int[long long int]' for array subscript
   78 |                         else ansid+=fark[i-1][0];
      |                                         ^