当前位置:网站首页>[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;
}
边栏推荐
- How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
- Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
- MIT CMS. 300 session 8 – immersion / immersion
- SQL injection vulnerability (MSSQL injection)
- The underlying structure of five data types in redis
- win10电脑系统里的视频不显示缩略图
- Microservice resource address
- The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
- Can CDC pull the Oracle table in full
- How to estimate the population with samples? (mean, variance, standard deviation)
猜你喜欢
[mathematical modeling] differential equation -- sustainable development of fishing industry
8. Static file
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
English Vocabulary - life scene memory method
canal同步mysql数据变化到kafka(centos部署)
Easyrecovery靠谱不收费的数据恢复电脑软件
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
11. Intranet penetration and automatic refresh
How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统
随机推荐
Project manager, can you draw prototypes? Does the project manager need to do product design?
C'est un petit résumé de l'étude.
acwing周赛58
Visio draws Tai Chi
[mathematical modeling] differential equation -- sustainable development of fishing industry
Supreme Court, judgment standard of divorce cases
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
Flody的应用
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
After learning classes and objects, I wrote a date class
IPv6 comprehensive experiment
优秀PM必须经历这3层蜕变!
Luogu deep foundation part 1 Introduction to language Chapter 2 sequential structure programming
内核判断i2c地址上是否挂载外设
[network] channel attention network and spatial attention network
[NOIP2008 提高组] 笨小猴
Tengine kernel parameters
Postman前置脚本-全局变量和环境变量
Yyds dry goods inventory OSI & tcp/ip