当前位置:网站首页>[lgr-109] Luogu may race II & windy round 6
[lgr-109] Luogu may race II & windy round 6
2022-07-06 04:46:00 【Zqchang】
P8344 「Wdoi-6」 Walking in the lotus field at night
P8344 「Wdoi-6」 Walking in the lotus field at night
This is to deduce a formula , Relatively simple , But at that time, the minus sign was written as a plus sign, and I didn't see it , speechless , Painted for more than ten minutes
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
int x, y, z;
signed main()
{
int t;
cin >> t;
while (t--)
{
cin >> x >> y >> z;
int p = x * z - (x + 1) * x / 2 + z - x;
if(x > z || p < y ) cout << "Merry" << endl;
else cout << "Renko" << endl;
}
return 0;
}
P8345 「Wdoi-6」 Hua Xu's dream
P8345 「Wdoi-6」 Hua Xu's dream
Some people talk nonsense about graph theory , Almost believed
It's also a push question , Write directly 
Pushed during the game
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
int a[N];
int n, c, q;
signed main()
{
fast;
cin >> n >> c >> q;
for (int i = 1; i <= n; i++) cin >> a[i];
vector<int> v;
while(q --)
{
v.clear();
int x, y; cin >> x;
int sum = 0;
for(int i=1; i<=x; i++)
{
cin >> y;
v.push_back(a[y]);
sum += a[y];
}
sort(v.begin(), v.end());
cout << (x - 1) * c - sum - v[x - 1] + 2 * v[0] << endl;
}
return 0;
}
P8346 「Wdoi-6」 The clearest air and sea
P8346 「Wdoi-6」 The clearest air and sea
The main idea of this question is 

Find out some hidden dangers of my code 

In the valley of Los Angeles ,vector You can't empty it like this
1e6 You're almost ready to use fast reading , Be careful STL, Here we use set Want to remove the heavy edge , to T 了 , Split
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bitsdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e6 + 10;
int n, m, t;
vector<int> mp[N];
int in[N];
int u, v;
set<PII> s;
bool vis[N];
signed main()
{
fast;
cin >> t;
while(t --)
{
cin >> n >> m;
for(int i=1; i<=m; i++)
{
cin >> u >> v;
v += n;
// if(s.count({u, v}) || s.count({v, u})) continue;
mp[u].push_back(v);
mp[v].push_back(u);
in[u] ++ ;
in[v] ++;
// s.insert({u, v});
}
n *= 2;
int res = 0;
queue<int> q;
for(int i=1; i<=n; i++) if(in[i] == 1) q.push(i);
while(q.size())
{
u = q.front();
q.pop();
if(vis[u] || in[u] != 1) continue;
vis[u] = 1;
in[u] --;
for(auto i: mp[u])
{
if(in[i] == 1 && !vis[i])
{
res ++;
in[i] --;
vis[i] = 1;
}
else if(!vis[i])
{
res ++;
vis[i] = 1;
for(auto j : mp[i])
{
-- in[i];
-- in[j];
if(in[j] == 1 && !vis[j]) q.push(j);
}
}
}
}
if(res == n / 2) cout << "Renko" << endl;
else cout << "Merry" << endl;
// s.clear();
for(int i=1; i<=n; i++)
{
in[i] = 0;
vis[i] = 0;
mp[i].clear();
}
}
return 0;
}
P8347 「Wdoi-6」 The moon on the other side
P8347 「Wdoi-6」 The moon on the other side
Questions and points for attention are in the code
The general method is , If you can find 
The circled structure , It must be the first to win , There are other situations , Not one by one , See for yourself if you want to see
Reference resources 1
Reference resources 2
!((n + 1) & n) Tell me about this judgment , This is judgment n+1 Is it right? 2 To the power of , That is, it can judge the full binary tree , Feel reference 1 It shouldn't be , Yes bug, I'll think about it again
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
int in[N];
vector<int> v[N];
bool dfs(int u, int fa)
{
for(auto i : v[u])
{
if(i == fa) continue;
if(!(in[u] & 1) && in[i] == 1) return true;
if(dfs(i, u)) return true;
}
return false;
}
signed main()
{
int t;
cin >> t;
while (t--)
{
int n; cin >> n;
int a, b;
for(int i=1; i<n; i++)
{
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
in[a] ++;
in[b] ++;
}
bool flag = 0;
for(int i=1; i<=n; i++)
if(in[i] != 2) flag = 0;
if(dfs(1, -1) || !((n + 1) & n)) cout << "Hifuu" << endl;
//!((n + 1) & n) This determines whether it is a full binary tree , But this judgment method is not rigorous , I don't know why I should make a special judgment
// Students have a way of writing , The same way of thinking , But he directly judges whether there is a degree 2 The point of , I can live , There is no need for special judgment
else cout << "Luna" << endl;
for(int i=1; i<=n; i++)
{
in[i] = 0;
v[i].clear();
}
}
return 0;
}
边栏推荐
- cdc 能全量拉去oracle 表嘛
- Embedded development program framework
- Orm-f & Q object
- What should the project manager do if there is something wrong with team collaboration?
- Can Flink SQL read multiple topics at the same time. How to write in with
- [HBZ sharing] how to locate slow queries in cloud database
- Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
- word封面下划线
- Postman测试报告
- [FreeRTOS interrupt experiment]
猜你喜欢

Digital children < daily question> (Digital DP)

Easyrecovery reliable and toll free data recovery computer software

Meet diverse needs: jetmade creates three one-stop development packages to help efficient development

Etcd database source code analysis -- etcdserver bootstrap initialization storage

IPv6 comprehensive experiment

The underlying structure of five data types in redis

8. Static file

Guitar Pro 8.0最详细全面的更新内容及全部功能介绍

Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)

ISP学习(2)
随机推荐
Platformio create libopencm3 + FreeRTOS project
Ue5 small knowledge points to enable the setting of lumen
C'est un petit résumé de l'étude.
Postman测试报告
MIT CMS. 300 session 8 – immersion / immersion
Chip debugging of es8316 of imx8mp
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Redis has four methods for checking big keys, which are necessary for optimization
Orm-f & Q object
树莓派3.5寸屏幕白屏显示连接
Flody的应用
Platformio create libopencm3 + FreeRTOS project
[detailed steps of FreeRTOS shift value for the first time]
On the solution of es8316's audio burst
ETCD数据库源码分析——etcdserver bootstrap初始化存储
win10电脑系统里的视频不显示缩略图
Introduction of several RS485 isolated communication schemes
Project manager, can you draw prototypes? Does the project manager need to do product design?
最高法院,离婚案件判决标准
canal同步mysql数据变化到kafka(centos部署)