-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwip.cpp
More file actions
134 lines (123 loc) · 3.39 KB
/
wip.cpp
File metadata and controls
134 lines (123 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <bits/stdc++.h>
using namespace std;
//#include <ext/rope>
//using namespace __gnu_cxx;
#include <ext/pb_ds/assoc_container.hpp>
#include <stdlib.h>
using namespace __gnu_pbds;
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#define inputJunk ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug cout<<"HERE"<<endl;
#define ell "\n"
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<int, pi> trip;
typedef pair<pll, ll> tripll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<trip> vtrip;
typedef vector<tripll> vtripll;
const int INF = 1e9+1212;
const ll INFL = 1e18+1221;
const ll P = 9973, M = 1e9+9;
const int MM = 1e5+5; int mod = 998244353;//1e9+7
int n, q; pi pts[MM], gap[MM];
template<class T> struct Seg { // comb(ID,b) = b
const T ID = 0; T comb(T a, T b) {
return a+b;
}
int n; vector<T> seg;
void init(int _n) { n = _n; seg.assign(2*n,ID); }
void pull(int p) { seg[p] = comb(seg[2*p],seg[2*p+1]); }
void upd(int p, T val) { // set val at position p
seg[p += n] = val; for (p /= 2; p; p /= 2) pull(p); }
T query(int l, int r) { // sum on interval [l, r]
T ra = ID, rb = ID;
for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
if (l&1) ra = comb(ra,seg[l++]);
if (r&1) rb = comb(seg[--r],rb);
}
return comb(ra,rb);
}
};
template<class T> struct Seg2 { // comb(ID,b) = b
const T ID = 0; T comb(T a, T b) {
return max(a, b);
}
int n; vector<T> seg;
void init(int _n) { n = _n; seg.assign(2*n,ID); }
void pull(int p) { seg[p] = comb(seg[2*p],seg[2*p+1]); }
void upd(int p, T val) { // set val at position p
seg[p += n] = val; for (p /= 2; p; p /= 2) pull(p); }
T query(int l, int r) { // sum on interval [l, r]
T ra = ID, rb = ID;
for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
if (l&1) ra = comb(ra,seg[l++]);
if (r&1) rb = comb(seg[--r],rb);
}
return comb(ra,rb);
}
};
Seg<int> s;
Seg2<int> s2;
int main(){
inputJunk
cin>>n>>q;
s.init(n+1);
for(int i = 0;i<n;i++){
int a, b; cin>>a>>b;
pts[i] = {a, b};
}
for(int i = 1;i<n;i++){
//cout<<pts[i].f<<" "<<pts[i-1].f<<" "<<pts[i].s<<" "<<pts[i-1].s<<ell;
gap[i] = {pts[i].f-pts[i-1].f, pts[i].s-pts[i-1].s};
s.upd(i, abs(gap[i].f)+abs(gap[i].s)+abs(gap[i-1].f)+abs(gap[i-1].s)});
if(i>=2){
s2.upd()
}
}
for(int i = 0;i<q;i++){
char a; int b, c; cin>>a>>b>>c;
if(a=='U'){
int d; cin>>d;
pts[b-1] = {c, d};
//2 upd functions
}else{
}
}
}
/*CUSTOM TEST CASE 1
*/
/*CUSTOM TEST CASE 2
*/
/*CUSTOM TEST CASE 3
*/
/*Comments of Shame
- floating error (use integer division instead)
- cin vs getline
- upperbound and lowerbound returns iteratorsf
- use long long when number is big enough
- for dp invalid cases needs to be skipped
- some base cases won't work (review cow poetry)
- always check bounds, some TLE are due to incorrect bounds!
- dont mess up return types
= RESET ARRAYS!!!!!!!!!!
- USE UR BRAIN
- INF setting problems
- push vs pb
- check if things are used properly
- read the PROBLEM (directed vs undirected graph)
*/
/*
freopen("time.in","r", stdin);
freopen("time.out","w", stdout);
*/