Submission #885783

#TimeUsernameProblemLanguageResultExecution timeMemory
885783AlphaMale06Sails (IOI07_sails)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long#define pb push_back#define F first#define S second const int N = 100003;int st[4*N];void Push(int v){if(!st[v])return;int rc=2*v+2;int lc=rc-1;st[lc]+=st[v];st[rc]+=st[v];st[v]=0;} int Get(int v, int l, int r, int ind){if(l>r || l>ind || r<ind)return 0;if(l==r)return st[v];Push(v);int mid=l+r>>1;return Get(2*v+1, l, mid, ind)+Get(2*v+2, mid+1, r, ind);}void Update(int v, int l, int r, int L, int R){if(l>r || l>R || r<L)return;if(l>=L && r<=R){st[v]++;return;}Push(v);int mid=l+r>>1;Update(2*v+1, l, mid, L, R);Update(2*v+2, mid+1, r, L, R);} signed main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;pair<int, int> a[n];for(int i=0; i< n; i++)cin >> a[i].F >> a[i].S;sort(a, a+n);for(int i=0; i< n; i++){int ind=a[i].F-a[i].S;int val=Get(0, 0, N-1, ind);int l=0; int r=ind;int mnind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){r=s-1;mnind=s;}else l=s+1;}l=ind; r=a[i].F-1;int mxind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){l=s+1;mxind=s;}else r=s-1;}Update(0, 0, N-1, mxind+1, a[i].F-1);Update(0, 0, N-1, mnind, mnind+a[i].S-a[i].F+mxind);}int ans=0;for(int i=0; i< N; i++){int gt=Get(0, 0, N-1, i);ans+=gt*(gt-1);}cout << ans/2 << '\n';}

Compilation message (stderr)

sails.cpp:1:25: error: extended character   is not valid in an identifier
    1 | #include <bits/stdc++.h> using namespace std; #define int long long#define pb push_back#define F first#define S second const int N = 100003;int st[4*N];void Push(int v){if(!st[v])return;int rc=2*v+2;int lc=rc-1;st[lc]+=st[v];st[rc]+=st[v];st[v]=0;} int Get(int v, int l, int r, int ind){if(l>r || l>ind || r<ind)return 0;if(l==r)return st[v];Push(v);int mid=l+r>>1;return Get(2*v+1, l, mid, ind)+Get(2*v+2, mid+1, r, ind);}void Update(int v, int l, int r, int L, int R){if(l>r || l>R || r<L)return;if(l>=L && r<=R){st[v]++;return;}Push(v);int mid=l+r>>1;Update(2*v+1, l, mid, L, R);Update(2*v+2, mid+1, r, L, R);} signed main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;pair<int, int> a[n];for(int i=0; i< n; i++)cin >> a[i].F >> a[i].S;sort(a, a+n);for(int i=0; i< n; i++){int ind=a[i].F-a[i].S;int val=Get(0, 0, N-1, ind);int l=0; int r=ind;int mnind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){r=s-1;mnind=s;}else l=s+1;}l=ind; r=a[i].F-1;int mxind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){l=s+1;mxind=s;}else r=s-1;}Update(0, 0, N-1, mxind+1, a[i].F-1);Update(0, 0, N-1, mnind, mnind+a[i].S-a[i].F+mxind);}int ans=0;for(int i=0; i< N; i++){int gt=Get(0, 0, N-1, i);ans+=gt*(gt-1);}cout << ans/2 << '\n';}
      |                         ^
sails.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h> using namespace std; #define int long long#define pb push_back#define F first#define S second const int N = 100003;int st[4*N];void Push(int v){if(!st[v])return;int rc=2*v+2;int lc=rc-1;st[lc]+=st[v];st[rc]+=st[v];st[v]=0;} int Get(int v, int l, int r, int ind){if(l>r || l>ind || r<ind)return 0;if(l==r)return st[v];Push(v);int mid=l+r>>1;return Get(2*v+1, l, mid, ind)+Get(2*v+2, mid+1, r, ind);}void Update(int v, int l, int r, int L, int R){if(l>r || l>R || r<L)return;if(l>=L && r<=R){st[v]++;return;}Push(v);int mid=l+r>>1;Update(2*v+1, l, mid, L, R);Update(2*v+2, mid+1, r, L, R);} signed main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;pair<int, int> a[n];for(int i=0; i< n; i++)cin >> a[i].F >> a[i].S;sort(a, a+n);for(int i=0; i< n; i++){int ind=a[i].F-a[i].S;int val=Get(0, 0, N-1, ind);int l=0; int r=ind;int mnind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){r=s-1;mnind=s;}else l=s+1;}l=ind; r=a[i].F-1;int mxind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){l=s+1;mxind=s;}else r=s-1;}Update(0, 0, N-1, mxind+1, a[i].F-1);Update(0, 0, N-1, mnind, mnind+a[i].S-a[i].F+mxind);}int ans=0;for(int i=0; i< N; i++){int gt=Get(0, 0, N-1, i);ans+=gt*(gt-1);}cout << ans/2 << '\n';}
      |                         ^~~~~~
sails.cpp:1:47: error: extended character   is not valid in an identifier
    1 | #include <bits/stdc++.h> using namespace std; #define int long long#define pb push_back#define F first#define S second const int N = 100003;int st[4*N];void Push(int v){if(!st[v])return;int rc=2*v+2;int lc=rc-1;st[lc]+=st[v];st[rc]+=st[v];st[v]=0;} int Get(int v, int l, int r, int ind){if(l>r || l>ind || r<ind)return 0;if(l==r)return st[v];Push(v);int mid=l+r>>1;return Get(2*v+1, l, mid, ind)+Get(2*v+2, mid+1, r, ind);}void Update(int v, int l, int r, int L, int R){if(l>r || l>R || r<L)return;if(l>=L && r<=R){st[v]++;return;}Push(v);int mid=l+r>>1;Update(2*v+1, l, mid, L, R);Update(2*v+2, mid+1, r, L, R);} signed main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;pair<int, int> a[n];for(int i=0; i< n; i++)cin >> a[i].F >> a[i].S;sort(a, a+n);for(int i=0; i< n; i++){int ind=a[i].F-a[i].S;int val=Get(0, 0, N-1, ind);int l=0; int r=ind;int mnind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){r=s-1;mnind=s;}else l=s+1;}l=ind; r=a[i].F-1;int mxind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){l=s+1;mxind=s;}else r=s-1;}Update(0, 0, N-1, mxind+1, a[i].F-1);Update(0, 0, N-1, mnind, mnind+a[i].S-a[i].F+mxind);}int ans=0;for(int i=0; i< N; i++){int gt=Get(0, 0, N-1, i);ans+=gt*(gt-1);}cout << ans/2 << '\n';}
      |                                              ^
sails.cpp:1:115: error: extended character   is not valid in an identifier
    1 | #include <bits/stdc++.h> using namespace std; #define int long long#define pb push_back#define F first#define S second const int N = 100003;int st[4*N];void Push(int v){if(!st[v])return;int rc=2*v+2;int lc=rc-1;st[lc]+=st[v];st[rc]+=st[v];st[v]=0;} int Get(int v, int l, int r, int ind){if(l>r || l>ind || r<ind)return 0;if(l==r)return st[v];Push(v);int mid=l+r>>1;return Get(2*v+1, l, mid, ind)+Get(2*v+2, mid+1, r, ind);}void Update(int v, int l, int r, int L, int R){if(l>r || l>R || r<L)return;if(l>=L && r<=R){st[v]++;return;}Push(v);int mid=l+r>>1;Update(2*v+1, l, mid, L, R);Update(2*v+2, mid+1, r, L, R);} signed main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;pair<int, int> a[n];for(int i=0; i< n; i++)cin >> a[i].F >> a[i].S;sort(a, a+n);for(int i=0; i< n; i++){int ind=a[i].F-a[i].S;int val=Get(0, 0, N-1, ind);int l=0; int r=ind;int mnind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){r=s-1;mnind=s;}else l=s+1;}l=ind; r=a[i].F-1;int mxind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){l=s+1;mxind=s;}else r=s-1;}Update(0, 0, N-1, mxind+1, a[i].F-1);Update(0, 0, N-1, mnind, mnind+a[i].S-a[i].F+mxind);}int ans=0;for(int i=0; i< N; i++){int gt=Get(0, 0, N-1, i);ans+=gt*(gt-1);}cout << ans/2 << '\n';}
      |                                                                                                                 ^
sails.cpp:1:252: error: extended character   is not valid in an identifier
    1 | #include <bits/stdc++.h> using namespace std; #define int long long#define pb push_back#define F first#define S second const int N = 100003;int st[4*N];void Push(int v){if(!st[v])return;int rc=2*v+2;int lc=rc-1;st[lc]+=st[v];st[rc]+=st[v];st[v]=0;} int Get(int v, int l, int r, int ind){if(l>r || l>ind || r<ind)return 0;if(l==r)return st[v];Push(v);int mid=l+r>>1;return Get(2*v+1, l, mid, ind)+Get(2*v+2, mid+1, r, ind);}void Update(int v, int l, int r, int L, int R){if(l>r || l>R || r<L)return;if(l>=L && r<=R){st[v]++;return;}Push(v);int mid=l+r>>1;Update(2*v+1, l, mid, L, R);Update(2*v+2, mid+1, r, L, R);} signed main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;pair<int, int> a[n];for(int i=0; i< n; i++)cin >> a[i].F >> a[i].S;sort(a, a+n);for(int i=0; i< n; i++){int ind=a[i].F-a[i].S;int val=Get(0, 0, N-1, ind);int l=0; int r=ind;int mnind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){r=s-1;mnind=s;}else l=s+1;}l=ind; r=a[i].F-1;int mxind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){l=s+1;mxind=s;}else r=s-1;}Update(0, 0, N-1, mxind+1, a[i].F-1);Update(0, 0, N-1, mnind, mnind+a[i].S-a[i].F+mxind);}int ans=0;for(int i=0; i< N; i++){int gt=Get(0, 0, N-1, i);ans+=gt*(gt-1);}cout << ans/2 << '\n';}
      |                                                                                                                                                                                                                                                         ^
sails.cpp:1:618: error: extended character   is not valid in an identifier
    1 | #include <bits/stdc++.h> using namespace std; #define int long long#define pb push_back#define F first#define S second const int N = 100003;int st[4*N];void Push(int v){if(!st[v])return;int rc=2*v+2;int lc=rc-1;st[lc]+=st[v];st[rc]+=st[v];st[v]=0;} int Get(int v, int l, int r, int ind){if(l>r || l>ind || r<ind)return 0;if(l==r)return st[v];Push(v);int mid=l+r>>1;return Get(2*v+1, l, mid, ind)+Get(2*v+2, mid+1, r, ind);}void Update(int v, int l, int r, int L, int R){if(l>r || l>R || r<L)return;if(l>=L && r<=R){st[v]++;return;}Push(v);int mid=l+r>>1;Update(2*v+1, l, mid, L, R);Update(2*v+2, mid+1, r, L, R);} signed main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin >> n;pair<int, int> a[n];for(int i=0; i< n; i++)cin >> a[i].F >> a[i].S;sort(a, a+n);for(int i=0; i< n; i++){int ind=a[i].F-a[i].S;int val=Get(0, 0, N-1, ind);int l=0; int r=ind;int mnind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){r=s-1;mnind=s;}else l=s+1;}l=ind; r=a[i].F-1;int mxind=ind;while(l<=r){int s=l+r>>1;int gt=Get(0, 0, N-1, s);if(gt==val){l=s+1;mxind=s;}else r=s-1;}Update(0, 0, N-1, mxind+1, a[i].F-1);Update(0, 0, N-1, mnind, mnind+a[i].S-a[i].F+mxind);}int ans=0;for(int i=0; i< N; i++){int gt=Get(0, 0, N-1, i);ans+=gt*(gt-1);}cout << ans/2 << '\n';}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ^