当前位置:网站首页>[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;
}
边栏推荐
- The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
- Digital children < daily question> (Digital DP)
- Postman测试报告
- NPM command -- install dependent packages -- Usage / explanation
- ORM aggregate query and native database operation
- CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
- tengine 内核参数
- Bubble sort
- [数学建模] 微分方程--捕鱼业的持续发展
- [NOIP2009 普及组] 分数线划定
猜你喜欢
![[detailed steps of FreeRTOS shift value for the first time]](/img/73/a469eb2465bb2c5acaa4d018d3edd3.jpg)
[detailed steps of FreeRTOS shift value for the first time]

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

RTP GB28181 文件测试工具

The most detailed and comprehensive update content and all functions of guitar pro 8.0

Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system

8. Static file

Canal synchronizes MySQL data changes to Kafka (CentOS deployment)

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

Crazy God said redis notes

Easyrecovery靠谱不收费的数据恢复电脑软件
随机推荐
Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
树莓派3.5寸屏幕白屏显示连接
Visio draw fan
DMA use of stm32
How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
Digital children < daily question> (Digital DP)
【HBZ分享】云数据库如何定位慢查询
Microservice resource address
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Is the mode of education together - on campus + off campus reliable
Redis 排查大 key 的4种方法,优化必备
【Try to Hack】john哈希破解工具
ue5 小知识 FreezeRendering 查看视锥内渲染的物体
牛顿插值法
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
Can CDC pull the Oracle table in full
Zynq learning notes (3) - partial reconfiguration
Postman测试报告