海亮 7.21 模拟赛
海亮 7.21 模拟赛
累了 随便打打 不切题就不切题罢
#A. 手语的 (gnsi)
只需要判断三倍重心点的
#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)
设置
那么显然有
那么我们可以看到答案是一段前缀和 记录一段前缀和就足够过
考虑继续优化 削减掉第二次操作 那么我们可以预处理
那么对于
那么
累加即可 时间复杂度
#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)
我的评价是:暴力出奇迹
#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;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)