当前位置:网站首页>Codeforces Round #804 (Div. 2)
Codeforces Round #804 (Div. 2)
2022-07-06 04:43:00 【Zqchang】
A. The Third Three Number Problem
A. The Third Three Number Problem
大意:给你一个n,让你求满足 的abc
做法就是用0呗,奇数1凑不出来,偶数0 0 n/2
#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;
signed main()
{
int t, n;
cin >> t;
while(t --)
{
cin >> n;
if(n & 1)
cout << -1 << endl;
else cout << 0 << " " << 0 << " " << n / 2 << endl;
}
return 0;
}
B. Almost Ternary Matrix
B. Almost Ternary Matrix
就是构造,但是注意,是它的邻居有且仅有两个跟他不一样,白wa3发
#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;
signed main()
{
int t, n, m;
cin >> t;
while(t --)
{
cin >> n >> m;
m /= 2;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
if(i % 4 == 1)
if(j & 1) cout << "1 0";
else cout <<"0 1";
else if(i % 4 == 2)
if(j & 1) cout <<"0 1";
else cout << "1 0";
else if(i % 4 == 3)
if(j & 1) cout <<"0 1";
else cout << "1 0";
else
if(j & 1) cout << "1 0";
else cout <<"0 1";
if(j == m) cout << endl;
else cout <<" ";
}
}
}
return 0;
}
C. The Third Problem
好题啊
一道题让我rk飙升
大意就是给你一个长为n的数组,内容是0到n-1,然后给你mex定义,说如果两组数中任意区间这俩的mex都相等,就说这两组数是相似的,然后给你一个数组,问你这个数组的相似数组有多少,包含他自己本身
做法:不知道叫啥,举个样例吧
8
1 3 7 2 5 0 6 4
用0和1位置不变先确定初始区间
一开始区间1 ~ 6,2的可能位置是数6-2=4,3的可能位置数是6-3=3,4在区间外面,所以4的可能位置数是1,然后这时候扩大区间,把4,扩进来,因为4已经确定位置了(可以这么想,枚举到4的时候,4前面的都在区间内被确定了,所以4就是外面最小的,它一动mex肯定变,所以它不能动,也就是位置固定),区间扩大为1~8,5的可能位置是8-5=3,6的可能位置2,7的可能位置8-7=1,332*4=72
#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 a[N];
map<int, int> mp;
set<int> s;
signed main()
{
int t, n, m;
cin >> t;
while(t --)
{
cin >> n;
int l1 = 0, r1 = 0, mex;
mp.clear();
s.clear();
for(int i=1; i<=n; i++)
{
cin >> a[i];
mp[a[i]] = i;
if(a[i] == 0) l1 = i;
if(a[i] == 1) r1 = i;
}
// for(int i=0; i<n; i++)
if(l1 > r1) swap(l1, r1);
// cout << "---"<< l1 <<" " << r1 << endl;
int res = 1;
for(int i=2; i<n; i++)
{
if(mp[i] < l1) l1 = mp[i];
else if(mp[i] > r1) r1 = mp[i];
else res *= r1 - l1 + 1 - i;
res %= MOD;
}
cout << res << endl;
for(int i=1; i<=n; i++) a[i] = 0;
}
return 0;
}
边栏推荐
- Easyrecovery reliable and toll free data recovery computer software
- Postman断言
- [Zhao Yuqiang] deploy kubernetes cluster with binary package
- Postman测试报告
- Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
- 麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
- Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
- 牛顿插值法
- Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps
- On the solution of es8316's audio burst
猜你喜欢
Distributed transaction solution
程序员在互联网行业的地位 | 每日趣闻
11. Intranet penetration and automatic refresh
ORM aggregate query and native database operation
Digital children < daily question> (Digital DP)
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
[数学建模] 微分方程--捕鱼业的持续发展
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
随机推荐
ETCD数据库源码分析——etcdserver bootstrap初始化存储
ORM aggregate query and native database operation
关于imx8mp的es8316的芯片调试
acwing周赛58
Delete subsequence < daily question >
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
win10电脑系统里的视频不显示缩略图
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
[try to hack] John hash cracking tool
内核判断i2c地址上是否挂载外设
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
【HBZ分享】云数据库如何定位慢查询
MySQL reported an error datetime (0) null
SharedPreferences 源码分析
ue5 小知识点 开启lumen的设置
Redis —— Redis In Action —— Redis 实战—— 实战篇一 —— 基于 Redis 的短信登录功能 —— Redis + Token 的共享 session 应用— 有代码
npm命令--安装依赖包--用法/详解
ue5 小知识 FreezeRendering 查看视锥内渲染的物体
【Try to Hack】john哈希破解工具
Embedded development program framework