#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; int n , m; int arr[1000000]; ll tree[1000000 * 4]; void build (int now, int s, int e){ if (s == e){ tree[now] = arr[s]; return; } int lch = now * 2, rch = lch + 1, m = (s + e) / 2; build(lc..
#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; struct D { int data; int index; bool operator < (const D& other) const { if(data == other.data) return index < other.index; return data < other.data; }; }; int arr[100005 * 2]; D tree[10000..
#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; int arr[100005 * 2]; int tree[100005 * 4]; int etd = -1000000002; int mn = 0; inline int Max(int a, int b){ return a>b ? a : b; } void build (int now, int s, int e){ if (s == e){ tree[now] ..
#include using namespace std; typedef pair p; vector g[101010]; int dist[101010]; int maxi[101010]; int chk[101010]; void dfs(int v, int d, int m){ dist[v] = d; maxi[v] = m; chk[v] = 1; for(auto i : g[v]){ if(!chk[i.first]) dfs(i.first, d + i.second, max(m, i.second)); } } int main(){ int n, a, b; cin >> n >> a >> b; for(int i=0; i> s >> e >> x; g[s].push_back({e, x}); g[e].push_back({s, x}); } ..
#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; typedef signed char i8; typedef short i16; typedef int i32; typedef long long i64; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int n, m; struct Path { int to; i16 need; }; struct QData { int where; int need; }; struct QD..
#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long ull; typedef pair pii; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int aMax, bMax; int aMake, bMake; struct QData { int a; int b; size_t operator()(const QData &pointToHash) const noexcept { size_t hash = pointToHash.a * 1000000 + poin..
#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long ull; typedef pair pii; typedef signed char i8; typedef short i16; typedef int i32; typedef long long i64; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int n; // wanna go int m; // cannot go bool canNotGo[105]; int price[105][10..
#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; pii parant[100005]; // pair int check[100005]; int checkNum = 1; int getTheSamePar(int a , int b) { while (1) { if(a != -1) { if(check[a] == checkNum) { checkNum++; retur..
#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long ull; typedef pair pii; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int initalL[13]; int divid[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, }; pair idxToXY[] = { {0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}..