Submission #1283116

#TimeUsernameProblemLanguageResultExecution timeMemory
1283116Faisal_SaqibFoehn Phenomena (JOI17_foehn_phenomena)C++20
Compilation error
0 ms0 KiB
/* VENI VIDI VICI */ #ifdef ONLINE_JUDGE #include <iostream> #include <vector> #include <algorithm> #include <set> #include <map> #include <string> #include <numeric> #include <chrono> #include <random> #include <cmath> #include <utility> #include <fstream> using namespace std; #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); using i128 = __int128; using ll = long long; using ull = unsigned long long; using ld = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vpi = vector<pair<int, int>>; using vvi = vector<vi>; using sll = set<ll>; template<class T> istream& operator>>(istream& is, vector<T>& v) { for(auto &i:v) is>>i; return is; } template<class T1,class T2> istream& operator>>(istream& is, pair<T1,T2>& p) { is>>p.fi>>p.se; return is; } template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { for(const auto &i:v) os<<i<<' '; return os; } template<class T1,class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& p) { os<<p.fi<<' '<<p.se; return os; } void pyn(bool x) { cout<<(x?"YES":"NO")<<endl; } void pYN(bool x) { cout<<(x?"Yes":"No")<<endl; } void pAB(bool x) { cout<<(x?"Alice":"Bob")<<endl; } ll powmod(ll a,ll b,ll modulo) { if(b==0){ return 1; } ll temp=powmod(a,b/2,modulo); if(b%2==0){ return (temp*temp)%modulo; } else{ return (a*((temp*temp)%modulo))%modulo; } } bool Prime(ll n){ for (ll i = 2; i*i <= n; i++) if (n % i == 0) return false; return (n>1); } void readIO() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } #endif void solve(); int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // readIO(); int uwu=1; // cin>>uwu; for(int tc=1;tc<=uwu;tc++) { // cout<<"Case #"<<tc<<": "; solve(); } return 0; } #define int ll const int N=2e5+10; ll a[N],fen[N],s,t; void add(int i,int v) { i++; while(i<N) { fen[i]+=v; i+=(i&-i); } } ll get(int x) { x++; ll ans=0; while(x>0) { ans+=fen[x]; x-=(x&-x); } return ans; } ll vala(int i) { return a[i]+get(i); } void Update(int l,int r,int x) { add(l,x); add(r+1,-x); // we want to add in the range [l,r] // add to prefix [1,r] // substract } ll wind=0; void contro(int i,ll v=1) // a[i-1]<a[i] { ll p=vala(i-1),q=vala(i); // cout<<"Contro "<<i<<' '<<p<<' '<<q<<' '<<v<<endl; if(p<q) { wind-=v*(q-p)*s; } else{ wind+=v*(p-q)*t; } } void solve() { ll n,q; cin>>n>>q>>s>>t; for(int i=0;i<=n;i++)cin>>a[i]; for(int i=1;i<=n;i++) { contro(i,1); } // cout<<"Init"<<endl; // cout<<wind<<endl; for(int i=0;i<q;i++) { int l,r,x; cin>>l>>r>>x; // a[l-1] a[l]+x a[l+1]+x .. a[r]+x a[r+1] contro(l,-1); if(r<n) contro(r+1,-1); Update(l,r,x); contro(l,1); if(r<n) contro(r+1,1); // for(int i=0;i<=n;i++) // { // cout<<vala(i)<<' '; // } // cout<<endl; cout<<wind<<endl; } }

Compilation message (stderr)

foehn_phenomena.cpp:98:1: error: 'int32_t' does not name a type
   98 | int32_t main() {
      | ^~~~~~~
foehn_phenomena.cpp:1:1: note: 'int32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
  +++ |+#include <cstdint>
    1 | /*
foehn_phenomena.cpp:113:13: error: 'll' does not name a type
  113 | #define int ll
      |             ^~
foehn_phenomena.cpp:114:7: note: in expansion of macro 'int'
  114 | const int N=2e5+10;
      |       ^~~
foehn_phenomena.cpp:115:1: error: 'll' does not name a type
  115 | ll a[N],fen[N],s,t;
      | ^~
foehn_phenomena.cpp:116:6: error: variable or field 'add' declared void
  116 | void add(int i,int v)
      |      ^~~
foehn_phenomena.cpp:113:13: error: 'll' was not declared in this scope
  113 | #define int ll
      |             ^~
foehn_phenomena.cpp:116:10: note: in expansion of macro 'int'
  116 | void add(int i,int v)
      |          ^~~
foehn_phenomena.cpp:113:13: error: 'll' was not declared in this scope
  113 | #define int ll
      |             ^~
foehn_phenomena.cpp:116:16: note: in expansion of macro 'int'
  116 | void add(int i,int v)
      |                ^~~
foehn_phenomena.cpp:125:1: error: 'll' does not name a type
  125 | ll get(int x)
      | ^~
foehn_phenomena.cpp:136:1: error: 'll' does not name a type
  136 | ll vala(int i)
      | ^~
foehn_phenomena.cpp:140:6: error: variable or field 'Update' declared void
  140 | void Update(int l,int r,int x)
      |      ^~~~~~
foehn_phenomena.cpp:113:13: error: 'll' was not declared in this scope
  113 | #define int ll
      |             ^~
foehn_phenomena.cpp:140:13: note: in expansion of macro 'int'
  140 | void Update(int l,int r,int x)
      |             ^~~
foehn_phenomena.cpp:113:13: error: 'll' was not declared in this scope
  113 | #define int ll
      |             ^~
foehn_phenomena.cpp:140:19: note: in expansion of macro 'int'
  140 | void Update(int l,int r,int x)
      |                   ^~~
foehn_phenomena.cpp:113:13: error: 'll' was not declared in this scope
  113 | #define int ll
      |             ^~
foehn_phenomena.cpp:140:25: note: in expansion of macro 'int'
  140 | void Update(int l,int r,int x)
      |                         ^~~
foehn_phenomena.cpp:148:1: error: 'll' does not name a type
  148 | ll wind=0;
      | ^~
foehn_phenomena.cpp:149:6: error: variable or field 'contro' declared void
  149 | void contro(int i,ll v=1) // a[i-1]<a[i]
      |      ^~~~~~
foehn_phenomena.cpp:113:13: error: 'll' was not declared in this scope
  113 | #define int ll
      |             ^~
foehn_phenomena.cpp:149:13: note: in expansion of macro 'int'
  149 | void contro(int i,ll v=1) // a[i-1]<a[i]
      |             ^~~
foehn_phenomena.cpp:149:19: error: 'll' was not declared in this scope
  149 | void contro(int i,ll v=1) // a[i-1]<a[i]
      |                   ^~
foehn_phenomena.cpp: In function 'void solve()':
foehn_phenomena.cpp:163:5: error: 'll' was not declared in this scope
  163 |     ll n,q;
      |     ^~
foehn_phenomena.cpp:164:5: error: 'cin' was not declared in this scope
  164 |     cin>>n>>q>>s>>t;
      |     ^~~
foehn_phenomena.cpp:164:10: error: 'n' was not declared in this scope
  164 |     cin>>n>>q>>s>>t;
      |          ^
foehn_phenomena.cpp:164:13: error: 'q' was not declared in this scope
  164 |     cin>>n>>q>>s>>t;
      |             ^
foehn_phenomena.cpp:164:16: error: 's' was not declared in this scope
  164 |     cin>>n>>q>>s>>t;
      |                ^
foehn_phenomena.cpp:164:19: error: 't' was not declared in this scope
  164 |     cin>>n>>q>>s>>t;
      |                   ^
foehn_phenomena.cpp:165:13: error: expected ';' before 'i'
  165 |     for(int i=0;i<=n;i++)cin>>a[i];
      |             ^
foehn_phenomena.cpp:165:17: error: 'i' was not declared in this scope
  165 |     for(int i=0;i<=n;i++)cin>>a[i];
      |                 ^
foehn_phenomena.cpp:165:31: error: 'a' was not declared in this scope
  165 |     for(int i=0;i<=n;i++)cin>>a[i];
      |                               ^
foehn_phenomena.cpp:166:13: error: expected ';' before 'i'
  166 |     for(int i=1;i<=n;i++)
      |             ^
foehn_phenomena.cpp:166:17: error: 'i' was not declared in this scope
  166 |     for(int i=1;i<=n;i++)
      |                 ^
foehn_phenomena.cpp:168:9: error: 'contro' was not declared in this scope
  168 |         contro(i,1);
      |         ^~~~~~
foehn_phenomena.cpp:173:13: error: expected ';' before 'i'
  173 |     for(int i=0;i<q;i++)
      |             ^
foehn_phenomena.cpp:173:17: error: 'i' was not declared in this scope
  173 |     for(int i=0;i<q;i++)
      |                 ^
foehn_phenomena.cpp:175:13: error: expected ';' before 'l'
  175 |         int l,r,x;
      |             ^
foehn_phenomena.cpp:176:14: error: 'l' was not declared in this scope
  176 |         cin>>l>>r>>x;
      |              ^
foehn_phenomena.cpp:176:17: error: 'r' was not declared in this scope
  176 |         cin>>l>>r>>x;
      |                 ^
foehn_phenomena.cpp:176:20: error: 'x' was not declared in this scope
  176 |         cin>>l>>r>>x;
      |                    ^
foehn_phenomena.cpp:178:9: error: 'contro' was not declared in this scope
  178 |         contro(l,-1);
      |         ^~~~~~
foehn_phenomena.cpp:181:9: error: 'Update' was not declared in this scope
  181 |         Update(l,r,x);
      |         ^~~~~~
foehn_phenomena.cpp:190:9: error: 'cout' was not declared in this scope
  190 |         cout<<wind<<endl;
      |         ^~~~
foehn_phenomena.cpp:190:15: error: 'wind' was not declared in this scope
  190 |         cout<<wind<<endl;
      |               ^~~~
foehn_phenomena.cpp:190:21: error: 'endl' was not declared in this scope
  190 |         cout<<wind<<endl;
      |                     ^~~~