제출 #1179747

#제출 시각아이디문제언어결과실행 시간메모리
1179747Szymon_PilipczukGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> int n; using namespace std; ll tr[400000]; #define ll long long void add(int l,int r,ll v) { l+=n; r+=n; tr[l]+=v; if(l!=r)tr[r]+=v; while(l/2 != r/2) { if(l%2 == 0)tr[l+1]+=v; if(r%2 == 1)tr[r-1]+=v; l/=2;r/=2; } } ll check(int p) { p+=n; int ans = 0; while(p > 0) { ans+=tr[p]; p/=2; } return ans; } int main() { cin>>n; int a[n]; for(int i =0 ;i<n;i++) { cin>>a[i]; tr[i+n] = a[i]; } ll ans = 0; int i = 1; int j = n-2; while(i <=j) { if(check(i-1) < check(i)) { i++; continue; } if(check(j+1) < check(j)) { j--; continue; } ans += min(check(j+1)-check(j)+1,check(i-1)-check(i)+1); add(i,j,min(check(j+1)-check(j)+1,check(i-1)-check(i)+1)); } if(check(i) == check(j)) { ans++; } cout<<ans; }

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

Main.cpp:4:1: error: 'll' does not name a type
    4 | ll tr[400000];
      | ^~
Main.cpp:4:1: note: the macro 'll' had not yet been defined
Main.cpp:5: note: it was later defined here
    5 | #define ll long long
      | 
Main.cpp: In function 'void add(int, int, long long int)':
Main.cpp:10:5: error: 'tr' was not declared in this scope; did you mean 'r'?
   10 |     tr[l]+=v;
      |     ^~
      |     r
Main.cpp: In function 'long long int check(int)':
Main.cpp:25:14: error: 'tr' was not declared in this scope; did you mean 'tm'?
   25 |         ans+=tr[p];
      |              ^~
      |              tm
Main.cpp: In function 'int main()':
Main.cpp:37:9: error: 'tr' was not declared in this scope; did you mean 'tm'?
   37 |         tr[i+n] = a[i];
      |         ^~
      |         tm