当前位置:网站首页>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;
}
边栏推荐
- Can Flink SQL read multiple topics at the same time. How to write in with
- Easyrecovery靠谱不收费的数据恢复电脑软件
- web工程导入了mysql驱动jar包却无法加载到驱动的问题
- Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
- Selection sort
- Quick sort
- [FreeRTOS interrupt experiment]
- Bubble sort
- [Zhao Yuqiang] deploy kubernetes cluster with binary package
- Programmers' position in the Internet industry | daily anecdotes
猜你喜欢
Visio draw fan
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Selection of slow motion function
Use sentinel to interface locally
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
Redis —— Redis In Action —— Redis 实战—— 实战篇一 —— 基于 Redis 的短信登录功能 —— Redis + Token 的共享 session 应用— 有代码
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
Basic knowledge and examples of binary tree
Digital children < daily question> (Digital DP)
Flody的应用
随机推荐
The video in win10 computer system does not display thumbnails
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
Uva1592 Database
[network] channel attention network and spatial attention network
Summary of redis AOF and RDB knowledge points
Basic knowledge and examples of binary tree
Quick sort
Mysql database storage engine
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
Flink kakfa data read and write to Hudi
ISP learning (2)
Postman测试报告
web工程导入了mysql驱动jar包却无法加载到驱动的问题
项目经理,你会画原型嘛?项目经理需要做产品设计了?
P2022 interesting numbers (binary & digit DP)
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
729. My schedule I (set or dynamic open point segment tree)
二叉树基本知识和例题
Postman前置脚本-全局变量和环境变量
Vulnerability discovery - vulnerability probe type utilization and repair of web applications