当前位置:网站首页>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;
}
边栏推荐
- Request (request object) and response (response object)
- 【Try to Hack】john哈希破解工具
- coreldraw2022新版本新功能介绍cdr2022
- ORM aggregate query and native database operation
- Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
- 几种RS485隔离通讯的方案介绍
- web工程导入了mysql驱动jar包却无法加载到驱动的问题
- Crazy God said redis notes
- [buuctf.reverse] 159_[watevrCTF 2019]Watshell
- Project manager, can you draw prototypes? Does the project manager need to do product design?
猜你喜欢
Crazy God said redis notes
Digital children < daily question> (Digital DP)
Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
Easyrecovery reliable and toll free data recovery computer software
The underlying structure of five data types in redis
CADD course learning (8) -- virtual screening of Compound Library
ISP learning (2)
Basic explanation of turtle module - draw curve
Database - MySQL storage engine (deadlock)
Distributed transaction solution
随机推荐
Can Flink SQL read multiple topics at the same time. How to write in with
Luogu deep foundation part 1 Introduction to language Chapter 2 sequential structure programming
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
729. My schedule I (set or dynamic open point segment tree)
The value of two date types is subtracted and converted to seconds
Easyrecovery reliable and toll free data recovery computer software
Canal synchronizes MySQL data changes to Kafka (CentOS deployment)
Introduction of several RS485 isolated communication schemes
Crazy God said redis notes
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
Summary of redis AOF and RDB knowledge points
Microservice resource address
Flody的应用
Supreme Court, judgment standard of divorce cases
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
[detailed steps of FreeRTOS shift value for the first time]
[Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
How to realize automatic playback of H5 video
Ue5 small knowledge points to enable the setting of lumen