海亮 7.21 模拟赛
海亮 7.21 模拟赛
累了 随便打打 不切题就不切题罢
#A. 手语的 (gnsi)
只需要判断三倍重心点的\(x,y\)坐标是否在三个矩形的\(x,y\)坐标最小值和最大值加和之内即可
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
int read ()
{
int x = 0 , f = 1;
char ch = cin.get();
while ( !isdigit ( ch ) ) { if ( ch == '-' ) f = -1; ch = cin.get(); }
while ( isdigit ( ch ) ) { x = ( x << 1 ) + ( x << 3 ) + ( ch ^ 48 ); ch = cin.get(); }
return x * f;
}
int xl[3] , xr[3] , yl[3] , yr[3];
signed main ()
{
ios::sync_with_stdio(false);
cin.tie(0) , cout.tie(0);
int T = read();
while ( T -- )
{
for ( int i = 0 ; i < 3 ; i ++ ) xl[i] = read() , xr[i] = read() , yl[i] = read() , yr[i] = read();
int x = read() , y = read();
cout << ( ( xl[0] + xl[1] + xl[2] <= 3 * x && xr[0] + xr[1] + xr[2] >= 3 * x && yl[0] + yl[1] + yl[2] <= 3 * y && yr[0] + yr[1] + yr[2] >= 3 * y ) ? "heihei" : "yiyandingzhen" ) << endl;
}
return 0;
}
#B. 序列的 (quencese)
设置\(dp_j\)表示以数字\(j\)为结尾的数列可能的状态
那么显然有\(dp_i=\sum_{j=1}^{\lfloor i\rfloor}dp_j\)
那么我们可以看到答案是一段前缀和 记录一段前缀和就足够过\(50\)的点 但还不够
考虑继续优化 削减掉第二次操作 那么我们可以预处理\(maxn^{\frac 1 4}\)以内的所有数组
那么对于\(i\) 它会对\(i^2\)及以后的\(dp\)值产生贡献
那么\(dp_i\)对答案的贡献就是\(dp_i*(sqrt(x)-i^2+1)\)
累加即可 时间复杂度\(O(maxn^{\frac 1 4})\)
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define int __int128
constexpr int mod = 998244353;
constexpr int N = 1e6 + 5;
char buf[1<<22] , *p1 , *p2;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin))?EOF:*p1++)
int read ()
{
int x = 0 , f = 1;
char ch = getchar();
while ( !isdigit ( ch ) ) { if ( ch == '-' ) f = -1; ch = getchar(); }
while ( isdigit ( ch ) ) { x = ( x << 1 ) + ( x << 3 ) + ( ch ^ 48 ); ch = getchar(); }
return x * f;
}
int n , x , f[N];
signed main ()
{
ios::sync_with_stdio(false);
cin.tie(0) , cout.tie(0);
f[1] = 1;
for ( int i = 2 ; i <= 100000 ; i ++ )
for ( int j = 1 ; j <= (int)sqrt((long double)i) ; j ++ ) f[i] += f[j];
int T = read();
while ( T -- )
{
x = read();
int xx = sqrt((long double)x);
int xxx = sqrt((long double)xx);
int ans = 0;
for ( int i = 1 ; i <= xxx ; i ++ )
ans += f[i] * ( xx - i * i + 1 );
cout << (long long)ans << endl;
}
return 0;
}
#D. 好的 (doog)
我的评价是:暴力出奇迹
\(50pts\)代码
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
constexpr int N = 5e5 + 5;
int read ()
{
int x = 0 , f = 1;
char ch = cin.get();
while ( !isdigit ( ch ) ) { if ( ch == '-' ) f = -1; ch = cin.get(); }
while ( isdigit ( ch ) ) { x = ( x << 1 ) + ( x << 3 ) + ( ch ^ 48 ); ch = cin.get(); }
return x * f;
}
int n , q , a[N] , buc[N];
string s;
void add ( int l , int r )
{
for ( int i = l ; i <= r ; i ++ ) a[i] = ( a[i] + 1 ) % 3;
}
int query ( int l , int r )
{
int pd = 1;
buc[0] = 0 , buc[1] = 0 , buc[2] = 0;
for ( int i = l ; i <= r ; i ++ ) buc[a[i]] ++;
if ( ( buc[0] & 1 ) || ( buc[1] & 1 ) || ( buc[2] & 1 ) ) pd = 0;
if ( pd == 0 ) return 0;
vector<int> vec;
for ( int i = l ; i <= r ; i ++ ) vec.push_back(a[i]);
while ( !vec.empty() )
{
bool jian = 1;
for ( int i = 0 ; i < (int)vec.size() - 1 ; i ++ ) if ( vec[i] == vec[i+1] ) vec.erase ( vec.begin() + i , vec.begin() + i + 2 ) , jian = 0;
if ( jian ) { pd = 0; break; }
}
return pd;
}
/*
8 9
01211012
2 4 5
2 3 6
1 6 8
1 6 8
2 3 6
2 1 8
1 1 1
1 7 7
2 1 8
*/
signed main ()
{
// freopen ( "doog1.in" , "r" , stdin );
// freopen ( "doog1.out" , "w" , stdout );
ios::sync_with_stdio(false);
cin.tie(0) , cout.tie(0);
n = read() , q = read();
cin >> s;
for ( int i = 1 ; i <= n ; i ++ ) a[i] = s[i-1] - '0';
while ( q -- )
{
int op = read() , l = read() , r = read();
if ( op == 1 ) add ( l , r );
else cout << ( query ( l , r ) ? "YES" : "NO" ) << endl;
}
return 0;
}