当前位置:网站首页>【LGR-109】洛谷 5 月月赛 II & Windy Round 6
【LGR-109】洛谷 5 月月赛 II & Windy Round 6
2022-07-06 04:43:00 【Zqchang】
P8344 「Wdoi-6」走在夜晚的莲台野
P8344 「Wdoi-6」走在夜晚的莲台野
这个就是推一个公式,比较简单,但是当时减号写成加号没看出来,无语,画了十多分钟
#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」华胥之梦
P8345 「Wdoi-6」华胥之梦
有人瞎说图论,差点信了
也是个推式子的题,就直接写
赛时推的
#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」最澄澈的空与海
这个题大意就是
这个题目找出来我代码的一些隐患吧
在洛谷,vector不能这么清空
1e6的读入差不多就要用快读了,注意STL,这里用set想去掉重边,给T了,裂开
#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」另一侧的月
疑问和注意点在代码里面
大致方法就是,如果能找到
圈起来的这种结构,就一定是先手必胜,此外还有别的情况,不一一列举了,想看的自己看吧
!((n + 1) & n)讲一下这个判断,这是判断n+1是不是2的幂次方的,也就是能判断满二叉树,感觉参考1不应该过,有bug,我再想想
#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)这个判断的是是否为满二叉树,但是这个判断方法感觉不严谨,不知道为什么要特判
//同学有种写法,思路一样,但是他直接判断有没有度是2的点,也能过,就不用特判了
else cout << "Luna" << endl;
for(int i=1; i<=n; i++)
{
in[i] = 0;
v[i].clear();
}
}
return 0;
}
边栏推荐
- 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
- Complete list of common functions of turtle module
- canal同步mysql数据变化到kafka(centos部署)
- Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
- It is also a small summary in learning
- win10电脑系统里的视频不显示缩略图
- ISP学习(2)
- P3500 [poi2010]tes intelligence test (two points & offline)
- Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
- Flink kakfa data read and write to Hudi
猜你喜欢
acwing周赛58
ORM aggregate query and native database operation
Certbot failed to update certificate solution
Uva1592 Database
How to realize automatic playback of H5 video
Basic explanation of turtle module - draw curve
[network] channel attention network and spatial attention network
[05-1, 05-02, 05-03] network protocol
11. Intranet penetration and automatic refresh
How does computer nail adjust sound
随机推荐
Database - MySQL storage engine (deadlock)
[Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
Quick sort
The most detailed and comprehensive update content and all functions of guitar pro 8.0
11. Intranet penetration and automatic refresh
几种RS485隔离通讯的方案介绍
Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
饼干(考试版)
Sqlserver query results are not displayed in tabular form. How to modify them
ue5 小知识 FreezeRendering 查看视锥内渲染的物体
最高法院,离婚案件判决标准
acwing周赛58
The video in win10 computer system does not display thumbnails
MIT CMS. 300 session 8 – immersion / immersion
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
内核判断i2c地址上是否挂载外设
[NOIP2009 普及组] 分数线划定
[detailed steps of FreeRTOS shift value for the first time]
Lagrange polynomial
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