MyPower

1601

Egbert-Lannister.

NoReason
sss_001

xumingming
weiwei3466

MuShan
zl_58

MyPower
2天前

## Day04

1. 依赖期
积极主动
以终为始
要事第一

2. 独立期
双赢思维
知彼解己
统合综效

3. 互赖期
不断更新（提升其他六个习惯的效率）
“人的行为总是不断地重复，所以卓越不是一时的行为，而是习惯。“ （亚里士多德）

# 阅读

MyPower
18天前
#include <iostream>
#include <algorithm>
#define x first
#define y second
using namespace std;

typedef pair<int, int> PII;
const int N = 100010;

PII q[N];
bool cmp(PII a, PII b)
{
return a.y < b.y;
}
int main()
{
int n;
scanf("%d", &n);
int a, b;
for(int i = 0; i < n; i ++)
{
cin >> a >> b;
q[i].x = a;
q[i].y = b;
// cout << q[i].x << " " << q[i].y << endl;
}
sort(q, q + n, cmp);
int ans = 0, t = 9e9;
for(int i = 0; i < n; i ++)
{
// cout << t << endl;
if(t >= q[i].x && t <= q[i].y) continue;
else
{
t = q[i].y;
ans ++;
}

}
printf("%d", ans);
}

MyPower
20天前
#include <iostream>

using namespace std;

const int N = 100010;

int a[N], b[N];
int main()
{
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i ++) cin >> a[i];
for(int i = 0; i < m; i ++) cin >> b[i];
int cnt = 0;
for(int i = 0, j = 0; i < n; i ++)
{
while(j < m - 1 && a[i] != b[j]) j ++;
if(a[i] == b[j])
{
cnt ++;
// cout << i << " " << j << endl;
j ++;
}
}
if(cnt == n) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

MyPower
24天前
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100010;

int a[N];
int main()
{
int n, k;
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i ++) cin >> a[i];
sort(a, a + n + 1);
cout << a[k] << endl;
return 0;
}

MyPower
24天前
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 210, INF = 1e9;

int n, m, q;

int d[N][N];

void floyd()
{
for(int k = 1; k <= n; k ++)
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= n; j ++)
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
int main()
{
scanf("%d%d%d", &n, &m, &q);
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= n; j++)
if(i == j) d[i][j] = 0;
else d[i][j] = INF;

while(m -- )
{
int a, b, w;
scanf("%d%d%d", &a, &b, &w);
d[a][b] = min(d[a][b], w);
}
floyd();
while(q --)
{
int a, b;
scanf("%d%d", &a, &b);
if(d[a][b] > INF / 2) cout << "impossible" << endl;
else printf("%d\n", d[a][b]);
}
return 0;
}

MyPower
1个月前
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <int> div(vector <int>& A, int b, int &r)
{
vector <int> C;
int t = 0;
for(int i = A.size(); i >= 0; i --)
{
r = r * 10 + A[i];
C.push_back(r / b);
r %= b;
}
reverse(C.begin(), C.end());
while(C.size() > 1 && C.back() == 0) C.pop_back();
return C;
}
vector <int> add(vector <int> A, int b)
{
vector <int> C;
int t = 0;
for(int i = 0; i < A.size(); i ++)
{
t += A[i];
if(b) t += b % 10;
C.push_back(t % 10);
t /= 10;
b /= 10;
}
if(t) C.push_back(t);
return C;
}

vector <int> mul(vector <int> A, int b)
{
vector <int> C;
int t = 0;
for(int i = 0; i < A.size(); i ++)
{
t += A[i] * b;
C.push_back(t % 10);
t /= 10;
}
if(t) C.push_back(t);
return C;
}
void print(vector <int> A)
{
for(int i = A.size() - 1; i >= 0 ; i --) cout << A[i];
cout << endl;
}
int main()
{
vector <int> a, b;
string s;
cin >> s;
for(int i = s.size() - 1; i >= 0; i --) a.push_back(s[i] - '0');
//将十进制转化为二进制
while(a.size() > 1 || a[0] > 0)
{
int r = 0;
a = div(a, 2, r);
b.push_back(r);
}
//将二进制逆序转化为十进制
vector <int> C{0};
for(int i = 0; i < b.size(); i ++)
{
C = mul(C, 2);
// print(C);
}
print(C);
return 0;
}

MyPower
1个月前
#include <bits/stdc++.h>

using namespace std;

const int N = 100010;

int p[N], siz[N];

int find(int x)
{
if(p[x] != x) p[x] = find(p[x]);
return p[x];
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i ++)
{
p[i] = i;
siz[i] = 1;
}
while(m --)
{
char op[5];
int a, b;
scanf("%s", op);
if(op[0] == 'C')
{
scanf("%d%d", &a, &b);
if(find(a) == find(b)) continue;
siz[find(b)] += siz[find(a)];//在合并两个树时, 先让b树加上a树的点的数量
p[find(a)] = find(b);
}
else if(op[1] == '1')
{
scanf("%d%d", &a, &b);
if(find(a) == find(b)) cout << "Yes" << endl;
else cout << "No" << endl;
}
else
{
scanf("%d", &a);
cout << siz[find(a)] << endl;
}

}
return 0;
}

MyPower
1个月前
#include <bits/stdc++.h>

using namespace std;

const int N = 1000010;

int p[N];

int find(int x)
{
if(p[x] != x) p[x] = find(p[x]);
return p[x];
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i ++) p[i] = i;
while(m --)
{
char op[2];
int a, b;
scanf("%s%d%d", op, &a, &b);
if(op[0] == 'M') p[find(a)] = find(b);
else
if(find(a) == find(b)) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}

MyPower
1个月前
#include <iostream>

using namespace std;

const int N = 1010;

int v[N], w[N], f[N][N];
int main()
{
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i ++) cin >> v[i] >> w[i];
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j ++)
{
f[i][j] = f[i - 1][j];
if(j >= v[i]) f[i][j] = max(f[i][j], f[i][j - v[i]] + w[i]);
}
cout << f[n][m];
return 0;
}

MyPower
1个月前

# include [HTML_REMOVED]

using namespace std;
vector [HTML_REMOVED] add(vector [HTML_REMOVED] &A, vector [HTML_REMOVED] &B)
{
vector [HTML_REMOVED] C;
if(A.size() < B.size()) return add(B, A);
//默认A大
//进位 开始是0
int t = 0;
for(int i = 0; i < A.size(); i )
{
t += A[i];
if(i < B.size()) t += B[i];
C.push_back(t % 10);
t /= 10;
if(i == A.size() - 1 && t == 1) C.push_back(t);
}
return C;
}
int main()
{
vector [HTML_REMOVED] x, y;
string a, b;
cin >> a >> b;
for(int i = 0; i < a.size(); i
) x.push_back(a[i] - ‘0’);
for(int i = 0; i < b.size(); i++) y.push_back(b[i] - ‘0’);
reverse(x.begin(), x.end());
reverse(y.begin(), y.end());//从地位到高位