yxc

600.3万

Pluto._72

Belous
Eureka_7

seraphlive
せつしようまる
18935227192
alphak12
zcming123xyz
acw_yc
wayy
D_deBUG
Marvelous.

liki_3
McKinleyLu

yxc
1天前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100010, M = N * 2;

int n;
int h[N], e[M], ne[M], idx;
int ans;

void add(int a, int b)  // 添加一条边a->b
{
e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int dfs(int u, int father)
{
int sz = 1;
for (int i = h[u]; ~i; i = ne[i])
{
int j = e[i];
if (j == father) continue;
int s = dfs(j, u);
if (s % 2 == 0) ans ++ ;
sz += s;
}
return sz;
}

int main()
{
scanf("%d", &n);

if (n % 2)
{
puts("-1");
return 0;
}

memset(h, -1, sizeof h);

for (int i = 0; i < n - 1; i ++ )
{
int a, b;
scanf("%d%d", &a, &b);
}

dfs(1, -1);

printf("%d\n", ans);
return 0;
}


yxc
1天前
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>

using namespace std;

int n, k;
unordered_map<int, int> mp;

int main()
{
cin >> n >> k;
for (int i = 1; i <= n; i ++ )
{
int x;
cin >> x;
mp[x] = i;
}

if (mp.size() < k) puts("NO");
else
{
puts("YES");
int cnt = 0;
for (auto [x, v]: mp)
{
if ( ++ cnt > k) break;
cout << v << ' ';
}
}

return 0;
}


yxc
5天前

$|f| = \sum_{(s, v) \in E}f(s, v) - \sum_{(u, s) \in E}f(u, s)$

yxc
5天前
ssh myserver
cd homework
mkdir lesson_5
cd lesson_5

git clone git@git.acwing.com:yxc/homework.git


yxc
5天前
git merge dev  # 将dev分支合并到当前分支

***
111
333
555
444
***

git commit -m "fix conflicts"


yxc
5天前
git checkout master  # 切换回master分支

***
111
333
555
***



yxc
5天前
git checkout -b dev
***
111
333
444
***



yxc
5天前

git remote add origin git@git.acwing.com:yxc/homework.git
git push -u origin master


yxc
5天前
rm problem2 -r
mkdir problem3
cd problem3
vim main.cpp
***
#include <iostream>

using namespace std;

const int N = 1010;

int n, m;
int f[N];

int main()
{
cin >> n >> m;

while (n -- )
{
int v, w;
cin >> v >> w;
for (int j = v; j <= m; j ++ )
f[j] = max(f[j], f[j - v] + w);
}

cout << f[m] << endl;
return 0;
}
***

cd ..
***
111
333
***

git commit -m "many operations"


yxc
5天前
mkdir problem1 problem2
cd problem1
vim main.cpp
***
#include <iostream>

using namespace std;

int main()
{
int a, b;
cin >> a >> b;
cout << a + b << endl;
return 0;
}
***
cd ../problem2
vim main.cpp
***
#include <iostream>

using namespace std;

const int N = 1010;

int n, m;
int f[N];

int main()
{
cin >> n >> m;
while (n -- )
{
int v, w;
cin >> v >> w;
for (int j = m; j >= v; j -- )
f[j] = max(f[j], f[j - v] + w);
}

cout << f[m] << endl;

return 0;
}
***
cd ..