QAQ

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using std::vector;
using std::sort;
int cmp(const void * x, const void * y) {
//x < y
#define datatype int
return (*((datatype *)(x))) > (*((datatype *)(y))) ? : -;
#undef datatype
}
char str[];
int l[], r[];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
scanf("%s", str);
int n = strlen(str);
memset(l, , sizeof(l));
if (str[] == 'Q') l[] = ;
memset(r, , sizeof(r));
if (str[n - ] == 'Q') r[n-] = ;
for (int i = ; i < n; i++) {
l[i] = l[i - ];
if (str[i] == 'Q') l[i]++;
}
for (int i = n - ; i >= ; i--) {
r[i] = r[i + ];
if (str[i] == 'Q') r[i]++;
}
int ans = ;
for (int i = ; i < n; i++) {
if (str[i] == 'A') ans += l[i] * r[i];
}
printf("%d\n", ans);
return ;
}

Ralph And His Magic Field

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include <iostream>
using namespace std;
/*using std::vector;
using std::sort;*/
int cmp(const void * x, const void * y) {
//x < y
#define datatype int
return (*((datatype *)(x))) > (*((datatype *)(y))) ? : -;
#undef datatype
}
class BigNum {
#define MAXSIZEOFBIGNUM 500
#define BASE 10
#define DLEN 1
public:
int Len;
int d[MAXSIZEOFBIGNUM];
public:
BigNum(void);
BigNum(const int);
BigNum(const long long);
BigNum(const char *);
BigNum(const BigNum &);
BigNum & operator = (const BigNum &);
void clear(void);
friend istream& operator>>(istream&, BigNum&);
friend ostream& operator<<(ostream&, BigNum&);
bool operator == (const BigNum &) const;
bool operator > (const BigNum &) const;
bool operator < (const BigNum &) const;
bool operator >= (const BigNum &) const;
bool operator <= (const BigNum &) const;
BigNum operator + (const BigNum &) const;
BigNum operator - (const BigNum &) const;
BigNum operator * (const BigNum &) const;
BigNum operator / (const BigNum &) const;
BigNum operator % (const BigNum &) const;
void operator ++ (void);
void operator -- (void);
BigNum operator + (const int &) const;
BigNum operator - (const int &) const;
BigNum operator * (const int &) const;
BigNum operator / (const int &) const;
int operator % (const int &) const;
BigNum operator ^ (const int &) const;
~BigNum() {}
};
BigNum::BigNum() {
Len = ;
memset(d, , sizeof(d));
}
BigNum::BigNum(const int ops) {
int x = ops;
if (ops == ) Len = ;
else Len = ;
memset(d, , sizeof(d));
while (x) {
Len++;
d[Len] = x % BASE;
x /= BASE;
}
}
BigNum::BigNum(const long long ops) {
long long x = ops;
if (ops == ) Len = ;
else Len = ;
memset(d, , sizeof(d));
while (x) {
Len++;
d[Len] = x % BASE;
x /= BASE;
}
}
BigNum::BigNum(const char * ops) {
int L = strlen(ops) - , b = ;
memset(d, , sizeof(d));
while (ops[b] == '') {
b++;
}
Len = ;
while (L - b + >= DLEN) {
int x = ;
for (int i = L - DLEN + ; i <= L; i++) {
x = x * + ops[i] - '';
}
Len++;
d[Len] = x;
L -= DLEN;
}
int x = ;
for (int i = b; i <= L; i++) {
x = x * + ops[i] - '';
}
Len++;
d[Len] = x;
}
BigNum::BigNum(const BigNum &ops) : Len(ops.Len) {
memset(d, , sizeof(d));
for (int i = ; i <= Len; i++) {
d[i] = ops.d[i];
}
}
BigNum & BigNum::operator = (const BigNum &ops) {
memset(d, , sizeof(d));
Len = ops.Len;
for (int i = ; i <= Len; i++) {
d[i] = ops.d[i];
}
return *this;
}
void BigNum::clear(void) {
for (int i = ; i <= MAXSIZEOFBIGNUM - ; i++) {
if (d[i] < ) {
d[i] += BASE;
d[i + ]--;
}
if (d[i] >= BASE) {
d[i] -= BASE;
d[i + ]++;
}
}
for (int i = MAXSIZEOFBIGNUM - ; i >= ; i--)
if (d[i] > ) {
Len = i;
return;
}
Len = ;
}
istream& operator>>(istream &in, BigNum &ops) {
char str[MAXSIZEOFBIGNUM + ];
in >> str;
int L = strlen(str), b = ;
while (str[b] == '') {
b++;
}
ops.Len = ;
for (int i = L - ; i >= b; i--) {
ops.Len++;
ops.d[ops.Len] = str[i] - '';
}
return in;
}
ostream& operator<<(ostream& out, BigNum& ops) {
for (int i = ops.Len; i >= ; i--) {
out << ops.d[i];
}
if (ops.Len == ) {
out << "";
}
return out;
}
bool BigNum::operator == (const BigNum &ops) const {
if (Len != ops.Len) {
return false;
}
for (int i = Len; i >= ; i--)
if (d[i] != ops.d[i]) {
return false;
}
return true;
}
bool BigNum::operator > (const BigNum &ops) const {
if (Len < ops.Len) {
return false;
} else if (Len > ops.Len) {
return true;
} else {
for (int i = Len; i >= ; i--)
if (d[i] < ops.d[i]) {
return false;
} else if (d[i] > ops.d[i]) {
return true;
}
}
return false;
}
bool BigNum::operator < (const BigNum &ops) const {
if (Len < ops.Len) {
return true;
} else if (Len > ops.Len) {
return false;
} else {
for (int i = Len; i >= ; i--)
if (d[i] < ops.d[i]) {
return true;
} else if (d[i] > ops.d[i]) {
return false;
}
}
return false;
}
bool BigNum::operator >= (const BigNum &ops) const {
if (Len < ops.Len) {
return false;
} else if (Len > ops.Len) {
return true;
} else {
for (int i = Len; i >= ; i--)
if (d[i] < ops.d[i]) {
return false;
} else if (d[i] > ops.d[i]) {
return true;
}
}
return true;
}
bool BigNum::operator <= (const BigNum &ops) const {
if (Len < ops.Len) {
return true;
} else if (Len > ops.Len) {
return false;
} else {
for (int i = Len; i >= ; i--)
if (d[i] < ops.d[i]) {
return true;
} else if (d[i] > ops.d[i]) {
return false;
}
}
return true;
}
BigNum BigNum::operator + (const BigNum &ops) const {
BigNum ret(*this);
for (int i = ; i <= ops.Len; i++) {
ret.d[i] += ops.d[i];
}
ret.clear();
return ret;
}
BigNum BigNum::operator - (const BigNum &ops) const {
BigNum ret(*this);
for (int i = ops.Len; i >= ; i--) {
ret.d[i] -= ops.d[i];
}
ret.clear();
return ret;
}
BigNum BigNum::operator * (const BigNum &ops) const {
BigNum ret, now(*this);
for (int i = ; i <= now.Len; i++)
for (int j = ; j <= ops.Len; j++) {
ret.d[i + j - ] += now.d[i] * ops.d[j];
}
for (int i = ; i <= MAXSIZEOFBIGNUM - ; i++)
if (ret.d[i] >= BASE) {
ret.d[i + ] += ret.d[i] / BASE;
ret.d[i] %= BASE;
}
for (int i = MAXSIZEOFBIGNUM - ; i >= ; i--)
if (ret.d[i] > ) {
ret.Len = i;
break;
}
return ret;
}
BigNum BigNum::operator / (const BigNum &ops) const {
BigNum now = (*this), div, mod;
div.Len = now.Len;
mod.Len = ;
for (int j = now.Len; j >= ; j--) {
mod.Len++;
for (int p = mod.Len; p >= ; p--) {
mod.d[p] = mod.d[p - ];
}
mod.d[] = now.d[j];
while (mod >= ops) {
div.d[j]++;
mod = mod - ops;
}
if (mod.Len == && mod.d[] == ) {
mod.Len--;
}
}
div.clear();
mod.clear();
return div;
}
BigNum BigNum::operator % (const BigNum &ops) const {
BigNum now = (*this), div, mod;
div.Len = now.Len;
mod.Len = ;
for (int j = now.Len; j >= ; j--) {
mod.Len++;
for (int p = mod.Len; p >= ; p--) {
mod.d[p] = mod.d[p - ];
}
mod.d[] = now.d[j];
while (mod >= ops) {
div.d[j]++;
mod = mod - ops;
}
if (mod.Len == && mod.d[] == ) {
mod.Len--;
}
}
div.clear();
mod.clear();
return mod;
}
void BigNum::operator ++ (void) {
d[]++;
for (int i = ; i <= MAXSIZEOFBIGNUM - ; i++)
if (d[i] >= BASE) {
d[i] -= BASE;
d[i + ]++;
} else {
break;
}
if (d[Len + ] > ) {
Len++;
}
}
void BigNum::operator -- (void) {
d[]--;
for (int i = ; i <= MAXSIZEOFBIGNUM - ; i++)
if (d[i] < ) {
d[i] += BASE;
d[i + ]--;
} else {
break;
}
if (d[Len] == ) {
Len--;
}
}
BigNum BigNum::operator + (const int & ops) const {
BigNum ret = (*this);
ret.d[] += ops;
ret.clear();
return ret;
}
BigNum BigNum::operator - (const int & ops) const {
BigNum ret = (*this);
ret.d[] -= ops;
ret.clear();
return ret;
}
BigNum BigNum::operator * (const int & ops) const {
BigNum ret(*this);
for (int i = ; i <= ret.Len; i++) {
ret.d[i] *= ops;
}
for (int i = ; i <= MAXSIZEOFBIGNUM - ; i++)
if (ret.d[i] >= BASE) {
ret.d[i + ] += ret.d[i] / BASE;
ret.d[i] %= BASE;
}
for (int i = MAXSIZEOFBIGNUM - ; i >= ; i--)
if (ret.d[i] > ) {
ret.Len = i;
return ret;
}
ret.Len = ;
return ret;
}
BigNum BigNum::operator / (const int & ops) const {
BigNum ret;
int down = ;
for (int i = Len; i >= ; i--) {
ret.d[i] = (d[i] + down * BASE) / ops;
down = d[i] + down * BASE - ret.d[i] * ops;
}
ret.Len = Len;
while (ret.d[ret.Len] == && ret.Len > ) {
ret.Len--;
}
return ret;
}
int BigNum::operator % (const int &ops) const {
int mod = ;
for (int i = Len; i >= ; i--) {
mod = ((mod * BASE) % ops + d[i]) % ops;
}
return mod;
}
BigNum BigNum::operator ^ (const int &ops) const {
BigNum t, ret();
if (ops == ) {
return ret;
}
if (ops == ) {
return *this;
}
int m = ops, i;
while (m > ) {
t = *this;
for (i = ; (i << ) <= m; i <<= ) {
t = t * t;
}
m -= i;
ret = ret * t;
if (m == ) {
ret = ret * (*this);
}
}
return ret;
}
long long n, m;
int k;
long long ans, mi;
int x[], len;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
scanf("%lld%lld%d", &n, &m, &k);
if (n % != m % && k == -) {
printf("0\n");
return ;
}
BigNum bn(n), bm(m);
BigNum power;
power = (bn - ) * (bm - );
len = ;
while (power > ) {
if (power % == ) x[len++] = ;
else x[len++] = ;
power = power / ;
}
mi = , ans = ;
if (x[]) ans *= ;
for (int i = ; i < len; i++) {
mi = (mi * mi) % ;
if (x[i]) {
ans = (ans * mi) % ;
}
}
printf("%lld\n", ans);
return ;
}

Marco and GCD Sequence

最小的数应该是所有数的约数

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include <iostream>
using std::vector;
using std::sort;
int cmp(const void * x, const void * y) {
//x < y
#define datatype int
return (*((datatype *)(x))) > (*((datatype *)(y))) ? : -;
#undef datatype
}
int s[];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int n, m;
scanf("%d", &n);
for (int i = ; i < n; i++) {
scanf("%d", &s[i]);
}
if (n == ) {
printf("1\n%d\n", s[]);
return ;
}
for (int i = ; i < n; i++) {
if (s[i] % s[] != ) {
printf("-1\n");
return ;
}
}
printf("%d\n", * n);
for (int i = ; i < n; i++) {
printf("%d %d ", s[], s[i]);
}
return ;
}

Ralph And His Tour in Binary Country

记录每个点到子树中各个点的距离,按从小到大排序,因为这是一个完全二叉树,所以排序的时候可以直接归并。

solve(x,h)表示从x节点开始往子树中走,以h的初始happy程度最多能获得的happy。

对于每次查询,首先从A点的子节点中找,然后向A点父亲的方向扩展,直到h耗尽或走到了所有点。

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint; lint a[];
vector<lint> G[], P[]; int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
} lint solve(int x, lint h) {
int ptr = lower_bound(G[x].begin(), G[x].end(), h) - G[x].begin();
return h * ptr - P[x][ptr - ];
} int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(), cin.tie();
int n, q, dep = ;
cin >> n >> q;
for (int i = ; i <= n; i++) cin >> a[i];
while ((dep << ) <= n) dep <<= ;
for (int i = dep; i <= n; i++) {
G[i].push_back();
} while (dep > ) {
for (int i = dep >> ; i < dep; i++) {
G[i].push_back();
int j = , k = , l = i << , r = (i << ) + ;
while (j < G[l].size() && k < G[r].size()) {
if (G[l][j] + a[l] < G[r][k] + a[r]) {
G[i].push_back(G[l][j] + a[l]);
j++;
} else {
G[i].push_back(G[r][k] + a[r]);
k++;
}
}
if (j == G[l].size()) for (int p = k; p < G[r].size(); p++) G[i].push_back(G[r][p] + a[r]);
else for (int p = j; p < G[l].size(); p++) G[i].push_back(G[l][p] + a[l]);
}
dep >>= ;
}
for (int i = ; i <= n; i++) {
P[i].push_back(G[i][]);
for (int j = ; j < G[i].size(); j++) {
P[i].push_back(P[i][j - ] + G[i][j]);
}
}
int x, y;
lint h;
while (q--) {
cin >> x >> h;
if (h == ) {
cout << << endl;
continue;
}
lint ans = solve(x, h);
while (x > ) {
if (a[x] < h) {
ans += h - a[x];
h -= a[x];
} else break;
y = (x >> ) << ;
if (y == x) y++;
x = (x >> );
if (y > n) continue;
if (a[y] < h) ans += solve(y, h - a[y]);
}
cout << ans << endl;
}
return ;
}

Ralph and Mushrooms

按照题解把代码写出来了,运行超时,大方向差不多,不想再调了。

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint; class Tarjan_Algorithm {
public:
int n;
vector<int> dfn, low;
vector<bool> inStack;
vector<vector<int> > * G;
int dep;
stack<int> pStack;
vector<vector<int> > Scc;
vector<int> color;
vector<pair<int, int> > bridge;
vector<int> component; void init(vector<vector<int> > * G, int size);
void dfs(int x);
void runTarjan();
};
void Tarjan_Algorithm::init(vector<vector<int> > * Graph, int size) {
if(size < ) return; G = Graph, n = size;
dfn.clear(), low.clear(), inStack.clear(), Scc.clear(), color.clear(), bridge.clear();
dfn = vector<int>(n + , );
low = vector<int>(n + , );
inStack = vector<bool>(n + , false);
color = vector<int>(n + , );
dep = ; while(!pStack.empty()) pStack.pop();
}
void Tarjan_Algorithm::dfs(int x) {
if(x > n) return; inStack[x] = true;
dfn[x] = low[x] = ++dep;
pStack.push(x); for(int i = ; i < (*G)[x].size(); i++) {
int u = (*G)[x][i]; if(dfn[u] == ) {
dfs(u);
low[x] = min(low[x], low[u]); if(dfn[x] < low[u]) {
bridge.push_back(make_pair(x, u));
}
} else {
if(inStack[u]) low[x] = min(low[x], dfn[u]);
}
} if(low[x] == dfn[x]) {
component.clear(); while(!pStack.empty()) {
int u = pStack.top();
pStack.pop();
component.push_back(u);
color[u] = Scc.size();
inStack[u] = false; if(u == x) break;
} Scc.push_back(component);
}
}
void Tarjan_Algorithm::runTarjan() {
for(int i = ; i <= n; i++) {
if(!dfn[i]) dfs(i);
}
} int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
} vector<vector<int> > G(, vector<int>()), P(, vector<int>());
vector<vector<int> > DAG(, vector<int>()), DAGP(, vector<int>());
queue<int> q;
lint dp[];
lint s[];
bool flag[];
Tarjan_Algorithm tja; lint calc(int x) {
int ll = , rr = ; while(ll < rr) {
int mm = (ll + rr + ) / ; if(mm * (mm + ) / > x)rr = mm - ;
else ll = mm;
} return x * (lint)(ll + ) - (lint)ll * (ll + ) * (ll + ) / ;
} int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(), cin.tie();
int n, m, x, y, c; while(cin >> n >> m) {
for(int i = ; i <= n; i++) G[i].clear(), P[i].clear(); for(int i = ; i < m; i++) {
cin >> x >> y >> c;
G[x].push_back(y);
P[x].push_back(c);
} tja.init(&G, n);
tja.runTarjan();
int nn = tja.Scc.size(); for(int i = ; i < nn; i++) DAG[i].clear(), DAGP[i].clear(); memset(s, , sizeof(s)); for(int i = ; i <= n; i++) {
x = tja.color[i]; for(int j = ; j < G[i].size(); j++) {
int u = G[i][j];
y = tja.color[u]; if(x != y) {
DAG[x].push_back(y);
DAGP[x].push_back(P[i][j]);
} else {
s[x] += calc(P[i][j]);
}
}
} memset(dp, , sizeof(dp));
int start;
cin >> start;
start = tja.color[start];
dp[start] = s[start]; while(!q.empty()) q.pop(); memset(flag, false, sizeof(flag));
q.push(start);
flag[start] = true; while(!q.empty()) {
int u = q.front();
q.pop();
flag[u] = false; for(int i = ; i < DAG[u].size(); i++) {
int v = DAG[u][i]; if(dp[v] < dp[u] + DAGP[u][i] + s[v]) {
dp[v] = dp[u] + DAGP[u][i] + s[v]; if(!flag[v]) {
q.push(v);
flag[v] = true;
}
}
}
} lint ans = ; for(int i = ; i < nn; i++) ans = max(ans, dp[i]); cout << ans << endl;
} return ;
}

Codeforces Round #447的更多相关文章

  1. Codeforces Round #447 (Div. 2) B. Ralph And His Magic Field 数学

    题目链接 题意:给你三个数n,m,k;让你构造出一个nm的矩阵,矩阵元素只有两个值(1,-1),且满足每行每列的乘积为k,问你多少个矩阵. 解法:首先,如果n,m奇偶不同,且k=-1时,必然无解: 设 ...

  2. Codeforces Round #447 (Div. 2) 题解 【ABCDE】

    BC都被hack的人生,痛苦. 下面是题解的表演时间: A. QAQ "QAQ" is a word to denote an expression of crying. Imag ...

  3. Codeforces Round #447 (Div. 2)

    我感觉这场CF还是比较毒的,虽然我上分了... Problem A  QAQ 题目大意:给你一个由小写字母构成的字符串,问你里面有多少个QAQ. 思路:找字符串中的A然后找两边的Q即可,可以枚举找Q, ...

  4. Codeforces Round #447 (Div. 2) 题解

    A.很水的题目,3个for循环就可以了 #include <iostream> #include <cstdio> #include <cstring> using ...

  5. Codeforces Round #447 (Div. 2) C 构造

    现在有一个长度为n的数列 n不超过4000 求出它的gcd生成set 生成方式是对<i,j> insert进去(a[i] ^ a[i+1] ... ^a[j]) i<=j 然而现在给 ...

  6. Codeforces Round #447 (Div. 2) C. Marco and GCD Sequence【构造/GCD】

    C. Marco and GCD Sequence time limit per test 1 second memory limit per test 256 megabytes input sta ...

  7. Codeforces Round #447 (Div. 2) B. Ralph And His Magic Field【数论/组合数学】

    B. Ralph And His Magic Field time limit per test 1 second memory limit per test 256 megabytes input ...

  8. Codeforces Round #447 (Div. 2) A. QAQ【三重暴力枚举】

    A. QAQ time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  9. Codeforces Round #447 (Div. 2)E. Ralph and Mushrooms

    Ralph is going to collect mushrooms in the Mushroom Forest. There are m directed paths connecting n  ...

随机推荐

  1. MAMP PRO php的session保存在哪里

    session的概念就不介绍了,最近接触php,很好奇session会保存在哪里. mac上用了MAMP PRO集成环境,作为服务器. 查了网上,说session的保存路径在php.ini中声明,于是 ...

  2. java操作Excel的poi 格式设置

    格式设置 package com.java.poi; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi. ...

  3. SSL证书在线申请和取回证书指南

    1.客服下单后用户会收到一封邮件,来验证接收证书的邮箱;如图1所示:只有完成此邮箱验证才能正常申请证书; 请注意:为了确保您或您的用户能正常收到WoSign证书管理系统自动发送的邮件,请一定要把系统发 ...

  4. PAT_A1110#Complete Binary Tree

    Source: PAT A1110 Complete Binary Tree (25 分) Description: Given a tree, you are supposed to tell if ...

  5. 接口测试与Postman

    阅读目录 1.接口测试简介 1.1 什么是接口测试  1.2 接口测试的必要性 1.3 接口测试流程 1.4 接口文档 1.5 接口测试用例设计 1.6 接口测试用例模板 2.Postman 2.1 ...

  6. UDP、线程、mutex锁(day15)

    一.基于UDP的网络编程模型 服务器端 .创建socket. .将fd和服务器的ip地址和端口号绑定 .recvfrom阻塞等待接收客户端数据 .业务处理 .响应客户端 客户端: .创建socket ...

  7. [bzoj3291] Alice与能源计划 (二分图最大匹配)

    传送门 Description 在梦境中,Alice来到了火星.不知为何,转眼间Alice被任命为火星能源部长,并立刻面临着一个严峻的考验.为 了方便,我们可以将火星抽象成平面,并建立平面直角坐标系. ...

  8. SOA架构设计的案例分析

    面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)进行拆分,并通过这些服务之间定义良好的接口和契约联系起来.接口是采用中立的方式进行定义的,它应该独立于实现服务的硬件平台. ...

  9. SOA案例架构分析浅谈

    上课中讲到了SOA架构设计,自己在课下决定总结一下对于SOA架构的理解以及应用. 先总结一下SOA的定义,SOA是面向服务架构,它可以根据需求通过网络对松散耦合的粗粒度应用组件进行分布式部署.组合和使 ...

  10. 【[Offer收割]编程练习赛15 B】分数调查

    [题目链接]:http://hihocoder.com/problemset/problem/1515 [题意] [题解] 带权并查集 relation[x]表示父亲节点比当前节点大多少; 对于输入的 ...