当前位置:网站首页>Codeforces Round #804 (Div. 2)
Codeforces Round #804 (Div. 2)
2022-07-06 04:47:00 【Zqchang】
A. The Third Three Number Problem
A. The Third Three Number Problem
Carelessness : To give you one n, Let you be satisfied Of abc
The way is to use 0 Chant , Odd number 1 I can't make it , even numbers 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
It's the structure , But notice , There are only two neighbors who are different from him , white wa3 Hair
#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
Good question
A question makes me rk soaring
The main idea is to give you a long for n Array of , The content is 0 To n-1, And then give you mex Definition , Say if there is any interval between two groups of numbers mex All equal , Say that these two groups of numbers are similar , Then I'll give you an array , How many similar arrays are there in this array , Including himself
practice : I don't know what it's called , Take an example
8
1 3 7 2 5 0 6 4
use 0 and 1 Determine the initial interval first if the position remains unchanged
At the beginning of the interval 1 ~ 6,2 The possible positions of are numbers 6-2=4,3 The number of possible positions of is 6-3=3,4 Outside the section , therefore 4 The number of possible positions of is 1, Then expand the range at this time , hold 4, Expand in , because 4 The location has been determined ( You can think so , Enumerate to 4 When ,4 The previous ones are determined in the interval , therefore 4 It's the smallest one outside , It moves mex Definitely change , So it can't move , That is to say, the position is fixed ), The range is expanded to 1~8,5 The possible location of is 8-5=3,6 Possible location of 2,7 Possible location of 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;
}
边栏推荐
- Etcd database source code analysis -- etcdserver bootstrap initialization storage
- 麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
- 优秀PM必须经历这3层蜕变!
- [05-1, 05-02, 05-03] network protocol
- The value of two date types is subtracted and converted to seconds
- 关于imx8mp的es8316的芯片调试
- 【LGR-109】洛谷 5 月月赛 II & Windy Round 6
- 8. Static file
- 牛顿插值法
- Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
猜你喜欢
Postman管理测试用例
SQL注入漏洞(MSSQL注入)
Ue5 small knowledge points to enable the setting of lumen
Crazy God said redis notes
几种RS485隔离通讯的方案介绍
Easyrecovery reliable and toll free data recovery computer software
How to realize automatic playback of H5 video
Use sentinel to interface locally
Weng Kai C language third week 3.1 punch in
[FreeRTOS interrupt experiment]
随机推荐
How does computer nail adjust sound
It is also a small summary in learning
Selection of slow motion function
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
Selection sort
Programmers' position in the Internet industry | daily anecdotes
ETCD数据库源码分析——etcdserver bootstrap初始化存储
Postman测试报告
Excellent PM must experience these three levels of transformation!
win10电脑系统里的视频不显示缩略图
Database - MySQL storage engine (deadlock)
MIT CMS. 300 session 8 – immersion / immersion
Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps
Basic explanation of turtle module - draw curve
P2022 interesting numbers (binary & digit DP)
11. Intranet penetration and automatic refresh
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
二叉树基本知识和例题
Bubble sort
Redis has four methods for checking big keys, which are necessary for optimization