当前位置:网站首页>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;
}
边栏推荐
- Selection of slow motion function
- Chip debugging of es8316 of imx8mp
- CADD course learning (8) -- virtual screening of Compound Library
- Knowledge consolidation source code implementation 3: buffer ringbuffer
- Basic explanation of turtle module - draw curve
- [Zhao Yuqiang] deploy kubernetes cluster with binary package
- Distributed transaction solution
- I'd like to ask about the current MySQL CDC design. In the full volume phase, if a chunk's binlog backfill phase,
- coreldraw2022新版本新功能介绍cdr2022
- What should the project manager do if there is something wrong with team collaboration?
猜你喜欢
[Zhao Yuqiang] deploy kubernetes cluster with binary package
8. Static file
IPv6 comprehensive experiment
[network] channel attention network and spatial attention network
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
Visio draws Tai Chi
11. Intranet penetration and automatic refresh
Digital children < daily question> (Digital DP)
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统
随机推荐
ETCD数据库源码分析——etcdserver bootstrap初始化存储
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
[HBZ sharing] how to locate slow queries in cloud database
麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东
The underlying structure of five data types in redis
Ue5 small knowledge freezerendering view rendered objects in the cone
Knowledge consolidation source code implementation 3: buffer ringbuffer
Platformio create libopencm3 + FreeRTOS project
The video in win10 computer system does not display thumbnails
It is also a small summary in learning
[Zhao Yuqiang] deploy kubernetes cluster with binary package
cdc 能全量拉去oracle 表嘛
[Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
[NOIP2009 普及组] 分数线划定
Orm-f & Q object
Flink kakfa data read and write to Hudi
acwing周赛58
canal同步mysql数据变化到kafka(centos部署)
Use sentinel to interface locally
After learning classes and objects, I wrote a date class