首页 > 其他分享 >「杂题乱刷」P3952

「杂题乱刷」P3952

时间:2024-02-15 19:55:55浏览次数:21  
标签:ss times push ans P3952 -- 杂题 define

链接

写的比较爽的一道小模拟。

交了 \(5\) 发之后才过,码力有待加强。

题意不说了。

第一版代码(73pts):

此代码样例没过,仅是想看看当前代码的得分。

点击查看代码
/*
Tips:
你数组开小了吗?
你MLE了吗?
你觉得是贪心,是不是该想想dp?
一个小时没调出来,是不是该考虑换题?
*/
#include<bits/stdc++.h>
using namespace std;
#define map unordered_map
#define forl(i,a,b) for(register long long i=a;i<=b;i++)
#define forr(i,a,b) for(register long long i=a;i>=b;i--)
#define lc(x) x<<1
#define rc(x) x<<1|1
#define mid (l+r)>>1
#define cin(x) scanf("%lld",&x)
#define cout(x) printf("%lld",x)
#define lowbit(x) x&-x
#define pb push_back
#define pf push_front
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
#define ll long long
ll t;
ll n;
string s,ss[110][5];
void solve()
{
	map<string,ll>mp;
	stack<string>q;
	stack<ll>times;
	cin>>n>>s;
	ll sum=0,pd=0,ans=0,S=0;
	forl(i,1,n)
	{
		cin>>ss[i][1];
		if(ss[i][1]=="E" && sum && !pd)
		{
			string st=q.top();
			mp[st]--;
			q.pop();
			sum--;
			S-=times.top();
			times.pop();
		}
		else if(ss[i][1]=="E")
			pd=1;
		else
		{
			sum++;
			ll num1=0,num2=0;
			forl(j,2,4)
			{
				cin>>ss[i][j];
				if(pd)
					continue;
				if(j==2)
				{
					q.push(ss[i][j]);
					mp[ss[i][j]]++;
					if(mp[ss[i][j]]>1)
						pd=1;
				}
				if(j==3)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						num1=100;
					else 
						num1=1e18;
				}
				if(j==4)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						num2=100;
					else 
						num2=1e18;
					if(num2-num1>1e17)
						times.push(1),S++,ans=max(ans,S);
					else
						times.push(0);
				}
			}
		}
	}
	if(pd || sum)
		cout<<"ERR\n";
	else
	{
		string nums="",last="";
		if(ans==0)
			last="O(1)";
		else
		{
			while(ans)
				nums+=ans%10+'0',ans/=10;
			reverse(nums.begin(),nums.end());
			last="O(n^"+nums+")";
		}
		if(last==s)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}
int main()
{
	IOS;
	t=1;
	cin>>t;
	while(t--)
		solve();
    /******************/
	/*while(L<q[i].l) */
	/*    del(a[L++]);*/
	/*while(L>q[i].l) */
	/*    add(a[--L]);*/
	/*while(R<q[i].r) */
	/*	  add(a[++R]);*/
	/*while(R>q[i].r) */
	/*    del(a[R--]);*/
    /******************/
	QwQ;
}

此代码 hack 数据:

in:

8
2 O(1)
F i 1 1
E
2 O(n^1)
F x 1 n
E
1 O(1)
F x 1 n
4 O(n^2)
F x 5 n
F y 10 n
E
E
4 O(n^2)
F x 9 n
E
F y 2 n
E
4 O(n^1)
F x 9 n
F y n 4
E
E
4 O(1)
F y n 4
F x 9 n
E
E
4 O(n^2)
F x 1 n
F x 1 10
E
E

out:

Yes
Yes
ERR
Yes
No
Yes
Yes
ERR

第二版代码(37pts)。

样例过了,然后提交。

点击查看代码
/*
Tips:
你数组开小了吗?
你MLE了吗?
你觉得是贪心,是不是该想想dp?
一个小时没调出来,是不是该考虑换题?
*/
#include<bits/stdc++.h>
using namespace std;
#define map unordered_map
#define forl(i,a,b) for(register long long i=a;i<=b;i++)
#define forr(i,a,b) for(register long long i=a;i>=b;i--)
#define lc(x) x<<1
#define rc(x) x<<1|1
#define mid (l+r)>>1
#define cin(x) scanf("%lld",&x)
#define cout(x) printf("%lld",x)
#define lowbit(x) x&-x
#define pb push_back
#define pf push_front
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
#define ll long long
ll t;
ll n;
string s,ss[110][5];
void solve()
{
	map<string,ll>mp;
	stack<string>q;
	stack<ll>times;
	cin>>n>>s;
	ll sum=0,pd=0,ans=0,S=0;
	forl(i,1,n)
	{
		cin>>ss[i][1];
		if(ss[i][1]=="E" && sum && !q.empty() && !times.empty() && !pd)
		{
			string st=q.top();
			mp[st]--;
			q.pop();
			sum--;
			S-=times.top();
			times.pop();
		}
		else if(ss[i][1]=="E")
			pd=1;
		else
		{
			sum++;
			ll num1=0,num2=0;
			forl(j,2,4)
			{
				cin>>ss[i][j];
				if(pd)
					continue;
				if(j==2)
				{
					q.push(ss[i][j]);
					mp[ss[i][j]]++;
					if(mp[ss[i][j]]>1)
						pd=1;
				}
				if(j==3)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						num1=100;
					else 
						num1=1e18;
				}
				if(j==4)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						num2=100;
					else 
						num2=1e18;
					if(num2-num1>1e17)
					{
						if(times.empty())
							times.push(1),S++,ans=max(ans,S);
						else
						{
							if(times.top()==1)
								times.push(1),S++,ans=max(ans,S);
							else
								times.push(0);
						}
					}
					else
						times.push(0);
					ans=max(ans,S);
				}
			}
		}
	}
	if(pd || sum)
		cout<<"ERR\n";
	else
	{
		string nums="",last="";
		if(ans==0)
			last="O(1)";
		else
		{
			while(ans)
				nums+=ans%10+'0',ans/=10;
			reverse(nums.begin(),nums.end());
			last="O(n^"+nums+")";
		}
		if(last==s)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}
int main()
{
	IOS;
	t=1;
	cin>>t;
	while(t--)
		solve();
    /******************/
	/*while(L<q[i].l) */
	/*    del(a[L++]);*/
	/*while(L>q[i].l) */
	/*    add(a[--L]);*/
	/*while(R<q[i].r) */
	/*	  add(a[++R]);*/
	/*while(R>q[i].r) */
	/*    del(a[R--]);*/
    /******************/
	QwQ;
}

此代码 hack 数据:

in:

2
8 O(n^2)
F a 57 n
F b 69 92
F c 85 87
F d 38 n
E
E
E
E
2 O(n^1)
F a 27 n
E

out:

Yes
Yes

第三版代码(73pts):

过了样例与前两个 hack 数据。

点击查看代码
/*
Tips:
你数组开小了吗?
你MLE了吗?
你觉得是贪心,是不是该想想dp?
一个小时没调出来,是不是该考虑换题?
*/
#include<bits/stdc++.h>
using namespace std;
#define map unordered_map
#define forl(i,a,b) for(register long long i=a;i<=b;i++)
#define forr(i,a,b) for(register long long i=a;i>=b;i--)
#define lc(x) x<<1
#define rc(x) x<<1|1
#define mid (l+r)>>1
#define cin(x) scanf("%lld",&x)
#define cout(x) printf("%lld",x)
#define lowbit(x) x&-x
#define pb push_back
#define pf push_front
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
#define ll long long
ll t;
ll n;
string s,ss[110][5];
void solve()
{
	map<string,ll>mp;
	stack<string>q;
	stack<ll>times;
	cin>>n>>s;
	ll sum=0,pd=0,ans=0,S=0;
	forl(i,1,n)
	{
		cin>>ss[i][1];
		if(ss[i][1]=="E" && sum && !q.empty() && !times.empty() && !pd)
		{
			string st=q.top();
			mp[st]--;
			q.pop();
			sum--;
			ll timetop=times.top();
			if(timetop==1)
				S--;
		//	S-=times.top();
			times.pop();
		}
		else if(ss[i][1]=="E")
			pd=1;
		else
		{
			sum++;
			ll num1=0,num2=0;
			forl(j,2,4)
			{
				cin>>ss[i][j];
				if(pd)
					continue;
				if(j==2)
				{
					q.push(ss[i][j]);
					mp[ss[i][j]]++;
					if(mp[ss[i][j]]>1)
						pd=1;
				}
				if(j==3)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						num1=100;
					else 
						num1=1e18;
				}
				if(j==4)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						num2=100;
					else 
						num2=1e18;
					if(num2-num1>1e17)
					{
						if(times.empty())
							times.push(1),S++,ans=max(ans,S);
						else
						{
							if(times.top()==1 || times.top()==-1)
								times.push(1),S++,ans=max(ans,S);
							else
								times.push(0);
						}
					}
					else
						times.push(-1);
					ans=max(ans,S);
				}
			}
		}
	}
	if(pd || sum)
		cout<<"ERR\n";
	else
	{
		string nums="",last="";
		if(ans==0)
			last="O(1)";
		else
		{
			while(ans)
				nums+=ans%10+'0',ans/=10;
			reverse(nums.begin(),nums.end());
			last="O(n^"+nums+")";
		}
		if(last==s)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}
int main()
{
	IOS;
	t=1;
	cin>>t;
	while(t--)
		solve();
    /******************/
	/*while(L<q[i].l) */
	/*    del(a[L++]);*/
	/*while(L>q[i].l) */
	/*    add(a[--L]);*/
	/*while(R<q[i].r) */
	/*	  add(a[++R]);*/
	/*while(R>q[i].r) */
	/*    del(a[R--]);*/
    /******************/
	QwQ;
}

此代码 hack 数据:

in:

2
54 O(n^9)
F a 8 n
F b 60 62
F c 20 n
F d 81 n
F e 70 n
F f 78 n
E
E
E
E
E
E
F a 76 n
F b 34 n
F c 16 n
F d 2 n
F e 5 n
F f 87 n
F g 8 n
F h 3 n
F i n 17
E
E
E
E
E
E
E
E
E
F a 90 n
F b 79 n
F c 24 n
F d 58 n
F e 58 n
F f 61 32
F g 5 n
F h 80 n
F i 54 n
F j 5 n
F k 79 97
F l 61 86
E
E
E
E
E
E
E
E
E
E
E
E
42 O(n^4)
F a 38 n
F b 7 n
F c n n
F d 79 n
F e 20 n
F f 99 7
F g 68 n
F h 74 n
F i 24 n
E
E
E
E
E
E
E
E
E
F a 10 n
F b 65 n
F c 45 91
F d n 7
F e 44 n
E
E
E
E
E
F a 75 n
F b 55 n
F c 82 39
F d 59 n
F e 38 n
F f 36 50
F g 40 n
E
E
E
E
E
E
E

out:

No
Yes

第四版代码(91pts):

过了样例及前三个 hack 数据。

点击查看代码
/*
Tips:
你数组开小了吗?
你MLE了吗?
你觉得是贪心,是不是该想想dp?
一个小时没调出来,是不是该考虑换题?
*/
#include<bits/stdc++.h>
using namespace std;
#define map unordered_map
#define forl(i,a,b) for(register long long i=a;i<=b;i++)
#define forr(i,a,b) for(register long long i=a;i>=b;i--)
#define lc(x) x<<1
#define rc(x) x<<1|1
#define mid (l+r)>>1
#define cin(x) scanf("%lld",&x)
#define cout(x) printf("%lld",x)
#define lowbit(x) x&-x
#define pb push_back
#define pf push_front
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
#define ll long long
ll t;
ll n;
string s,ss[110][5];
void solve()
{
	map<string,ll>mp;
	stack<string>q;
	stack<ll>times;
	cin>>n>>s;
	ll sum=0,pd=0,ans=0,S=0;
	forl(i,1,n)
	{
		cin>>ss[i][1];
		if(ss[i][1]=="E" && sum && !q.empty() && !times.empty() && !pd)
		{
			string st=q.top();
			mp[st]--;
			q.pop();
			sum--;
			ll timetop=times.top();
			if(timetop==1)
				S--;
		//	S-=times.top();
			times.pop();
		}
		else if(ss[i][1]=="E")
			pd=1;
		else
		{
			sum++;
			ll num1=0,num2=0;
			forl(j,2,4)
			{
				cin>>ss[i][j];
				if(pd)
					continue;
				if(j==2)
				{
					q.push(ss[i][j]);
					mp[ss[i][j]]++;
					if(mp[ss[i][j]]>1)
						pd=1;
				}
				if(j==3)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						forl(k,0,ss[i][j].size()-1)
							num1*=10,num1+=ss[i][j][k]-'0';
					else 
						num1=1e18;
				}
				if(j==4)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						forl(k,0,ss[i][j].size()-1)
							num2*=10,num2+=ss[i][j][k]-'0';						
					else 
						num2=1e18;
					if(num1>num2)
						times.push(0);
					else if(num2-num1>1e17)
					{
						if(times.empty())
							times.push(1),S++,ans=max(ans,S);
						else
						{
							if(times.top()==1 || times.top()==-1)
								times.push(1),S++,ans=max(ans,S);
							else
								times.push(0);
						}
					}
					else
						times.push(-1);
					ans=max(ans,S);
				}
			}
		}
	}
	if(pd || sum)
		cout<<"ERR\n";
	else
	{
		string nums="",last="";
		if(ans==0)
			last="O(1)";
		else
		{
			while(ans)
				nums+=ans%10+'0',ans/=10;
			reverse(nums.begin(),nums.end());
			last="O(n^"+nums+")";
		}
		if(last==s)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}
int main()
{
	IOS;
	t=1;
	cin>>t;
	while(t--)
		solve();
    /******************/
	/*while(L<q[i].l) */
	/*    del(a[L++]);*/
	/*while(L>q[i].l) */
	/*    add(a[--L]);*/
	/*while(R<q[i].r) */
	/*	  add(a[++R]);*/
	/*while(R>q[i].r) */
	/*    del(a[R--]);*/
    /******************/
	QwQ;
}

此代码 hack 数据:

in:

9
22 O(n^7)
F a 70 94
F b 90 94
E
E
F a 29 n
F b 22 n
F c 4 27
F d 85 n
F e 24 n
F f 56 87
F g 19 66
F h 6 41
F i 78 92
F j 7 n
E
E
E
E
E
E
E
E
66 O(n^8)
F a 87 n
F b 70 n
F c 65 n
F d 85 n
F e 35 n
E
E
E
E
E
F a 33 59
F b 74 n
F c 3 n
F d 81 88
F e 82 97
F f 87 98
F g 49 88
F h 72 98
F i 56 n
F j 48 76
F k 90 n
F l 54 n
F m 86 n
E
E
E
E
E
E
E
E
E
E
E
E
E
F a 32 46
F b 56 n
F c 5 n
F d 65 75
F e 4 n
F f 78 n
F g 75 n
F h 82 n
F i 52 n
F j 53 n
E
E
E
E
E
E
E
E
E
E
E
E
F a 3 n
F b 6 n
F c 22 n
F d 42 n
E
E
E
E
60 O(n^11)
F a 46 n
F b 3 64
F c 8 n
F d 19 n
F e 30 n
F f 22 16
F g 40 n
F h 10 n
F i 25 n
F a 62 n
E
E
E
E
E
E
E
E
E
E
F a 81 n
F b 37 n
F c 44 n
F d 13 n
F e 56 94
E
E
E
E
E
F a 50 n
F b 75 n
F c 3 74
F d 58 n
F e 15 n
F f 43 n
F g 32 n
F h 25 35
F i 47 n
F j 56 n
F k 53 81
F l 63 n
F m 78 87
F o 73 n
F p 90 n
E
E
E
E
E
E
E
E
E
E
E
E
E
E
E
36 O(n^7)
F a 68 n
F b 42 n
F c 16 n
F d 26 89
E
E
E
E
F a 7 44
F b 13 60
F c 85 97
F d 38 74
F e 73 n
F f 65 83
F g 52 n
F h 3 5
F i 88 n
F j 24 n
F k 81 n
F l 1 n
F m 85 n
E
E
E
E
E
E
E
E
E
E
E
E
E
F a 36 67
E
84 O(n^11)
F a 85 86
F b 76 90
F c 45 75
F d 41 43
F e 87 96
F f 18 n
F g 15 76
F h 47 n
E
E
E
E
E
E
E
E
F a 61 n
F b 62 n
F c 3 32
F d 4 n
F e 18 n
F f 53 74
F g 64 n
F h 87 n
F i 77 n
F j 60 69
F k 67 96
F l 34 n
F m 62 n
E
E
E
E
E
E
E
E
E
E
E
E
E
F a 74 n
F b 17 n
F c 9 n
F d 43 n
F e 82 n
F f 57 65
F g 35 n
F h 29 n
F i 37 95
E
E
E
E
E
E
E
E
E
F a 31 n
F b 14 71
F c 74 n
F d 81 n
F e 8 n
F f 11 n
F g 29 n
F h 19 n
F i 60 n
F j 68 79
F k 63 n
F l 11 n
E
E
E
E
E
E
E
E
E
E
E
E
62 O(n^10)
F a 26 n
F b 84 n
F c 69 73
F d 59 n
F e 13 n
E
E
E
E
E
F a 46 n
F b 61 n
F c 47 n
F d 43 n
F e 77 n
F f 33 n
F g 32 n
F h 71 n
F i n n
F j 35 n
F k 47 86
F l 53 n
E
E
E
E
E
E
E
E
E
E
E
E
F a 31 38
F b 74 95
F c 6 66
F d 68 84
F e 72 n
F f 1 n
F g 47 89
F h 89 n
F i 5 n
F j 34 n
F k 2 n
F l 27 n
E
E
E
E
E
E
E
E
E
E
E
E
F a 33 58
F b 5 70
E
E
34 O(n^4)
F a 50 n
F b 6 78
F c 9 10
F d 6 n
F e 17 n
F f 24 n
E
E
E
E
E
E
F a 50 56
F b 2 17
F c 57 n
F d 46 86
F e 38 60
F f 56 n
F g 77 94
F h 26 71
F i 59 n
F j 22 40
F k 13 n
E
E
E
E
E
E
E
E
E
E
E
56 O(n^5)
F a 9 n
F b 64 n
F c 17 n
F d n 6
F e 59 n
F f 36 n
F g 48 64
F h 17 n
E
E
E
E
E
E
E
E
F a 20 n
F b 19 n
F c 18 55
F d 46 n
F e 58 70
F f 12 46
E
E
E
E
E
E
F a 20 n
F b 35 n
F c 44 67
F d 40 49
F e 71 75
F f 61 n
F g 76 n
F h 3 n
F i 99 60
F j 59 80
F k 27 n
F l 30 n
F m 5 n
F o 86 n
E
E
E
E
E
E
E
E
E
E
E
E
E
E
2 O(n^1)
F a n n
E

out:

ERR
ERR
ERR
Yes
No
Yes
Yes
Yes
No

第五版代码(100pts):

此代码 AC 了此题。

点击查看代码
/*
Tips:
你数组开小了吗?
你MLE了吗?
你觉得是贪心,是不是该想想dp?
一个小时没调出来,是不是该考虑换题?
*/
#include<bits/stdc++.h>
using namespace std;
#define map unordered_map
#define forl(i,a,b) for(register long long i=a;i<=b;i++)
#define forr(i,a,b) for(register long long i=a;i>=b;i--)
#define lc(x) x<<1
#define rc(x) x<<1|1
#define mid (l+r)>>1
#define cin(x) scanf("%lld",&x)
#define cout(x) printf("%lld",x)
#define lowbit(x) x&-x
#define pb push_back
#define pf push_front
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
#define ll long long
ll t;
ll n;
string s,ss[110][5];
void solve()
{
	map<string,ll>mp;
	stack<string>q;
	stack<ll>times;
	cin>>n>>s;
	ll sum=0,pd=0,ans=0,S=0;
	forl(i,1,n)
	{
		cin>>ss[i][1];
		if(ss[i][1]=="E" && sum && !q.empty() && !times.empty() && !pd)
		{
			string st=q.top();
			mp[st]--;
			q.pop();
			sum--;
			ll timetop=times.top();
			if(timetop==1)
				S--;
		//	S-=times.top();
			times.pop();
		}
		else if(ss[i][1]=="E")
			pd=1;
		else
		{
			sum++;
			ll num1=0,num2=0;
			forl(j,2,4)
			{
				cin>>ss[i][j];
				if(pd)
					continue;
				if(j==2)
				{
					q.push(ss[i][j]);
					mp[ss[i][j]]++;
					if(mp[ss[i][j]]>1)
						pd=1;
				}
				if(j==3)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						forl(k,0,ss[i][j].size()-1)
							num1*=10,num1+=ss[i][j][k]-'0';
					else 
						num1=1e18;
				}
				if(j==4)
				{
					if(ss[i][j][0]>='0' && ss[i][j][0]<='9')
						forl(k,0,ss[i][j].size()-1)
							num2*=10,num2+=ss[i][j][k]-'0';						
					else 
						num2=1e18;
					if(num1>num2)
						times.push(0);
					else if(!times.empty() && times.top()==0)
						times.push(0);
					else if(num2-num1>1e17)
					{
						if(times.empty())
							times.push(1),S++,ans=max(ans,S);
						else
						{
							if(times.top()==1 || times.top()==-1)
								times.push(1),S++,ans=max(ans,S);
							else
								times.push(0);
						}
					}
					else
						times.push(-1);
					ans=max(ans,S);
				}
			}
		}
	//	cout<<S<<endl;
	}
	if(pd || sum)
		cout<<"ERR\n";
	else
	{
		string nums="",last="";
		if(ans==0)
			last="O(1)";
		else
		{
			while(ans)
				nums+=ans%10+'0',ans/=10;
			reverse(nums.begin(),nums.end());
			last="O(n^"+nums+")";
		}
		if(last==s)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}
int main()
{
	IOS;
	t=1;
	cin>>t;
	while(t--)
		solve();
    /******************/
	/*while(L<q[i].l) */
	/*    del(a[L++]);*/
	/*while(L>q[i].l) */
	/*    add(a[--L]);*/
	/*while(R<q[i].r) */
	/*	  add(a[++R]);*/
	/*while(R>q[i].r) */
	/*    del(a[R--]);*/
    /******************/
	QwQ;
}

标签:ss,times,push,ans,P3952,--,杂题,define
From: https://www.cnblogs.com/wangmarui/p/18016517

相关文章

  • 海亮02/15杂题
    海亮02/15杂题个人题单T2link题意给定一个\(n\)个点,\(m\)条边的仙人掌,每条边至多存在于一个环。你可以进行如下操作:选择一个度数为奇数的点,把与其相连的边全部删去。创建一个新的图,新图有\(2n\)个点。假如原图的编号为\(1\simn\),则若原图中\(u,v\)有边,则新图中......
  • 【无评级杂题】DP/贪心
    题目这题后来看了看网上的思路,发现贪心就能做,亏我还写了个O(2*N)的DP...浪费时间了属于是my-code#include<iostream>#include<cstring>#include<string>#include<cstdio>#include<cstdlib>#include<algorithm>#include<stack>#include<queue>......
  • 「杂题乱刷」洛谷 P1831
    题目链接一道简单数位dp题。多设一个支点和力矩和然后套板子就做完了。参考代码:点击查看代码/*Tips:你数组开小了吗?你MLE了吗?你觉得是贪心,是不是该想想dp?一个小时没调出来,是不是该考虑换题?*/#include<bits/stdc++.h>usingnamespacestd;#definemapunordered_m......
  • 交互杂题选做
    交互杂题选做记录一些自己写过的很有意思的交互题。另外JOISC中有很多有意思的交互题,很值得一做。CF1292ERinandTheUnknownFlower题意:交互题,你要猜一个长为\(n\)的由\(CHO\)构成的字符串,你每次可以询问一个长度为\(t\)的字符串,代价是\(\dfrac{1}{t^2}\),你会得到......
  • 海亮02/14杂题
    海亮2月14日个人题单T1link题意传奇特级大师\(\mathsfE\color{red}\mathsf{ntropyIncreaser}\)有一个\(n\timesm\)的矩形纸片,她将其放置在一个平面直角坐标系中,使其左下角在\((0,0)\),右上角在\((n,m)\)位置。她每次会均匀随机选择一条平行于坐标轴、经过坐标均为......
  • 「杂题乱刷」洛谷 P10155
    题目链接P10155[LSOT-2]基于二分查找与插入的快速排序解题思路算法一:容易发现,当\(a_n\)不为\(n\)时,我们无论如何都无法将\(n\)这个值插入到最后一位,否则我们可以依次将所有数字从大到小插入,这样也可以保证失去最少的贡献。视写法获得\(40\)分或\(60\)分。算法二......
  • 「杂题乱刷」P8687
    题目链接最典的状压dp了。直接枚举每个状态然后用01背包的方式做即可。时间复杂度\(O(n2^m)\)。代码:点击查看代码/*Tips:你数组开小了吗?你MLE了吗?你觉得是贪心,是不是该想想dp?一个小时没调出来,是不是该考虑换题?*/#include<bits/stdc++.h>usingnamespacestd;......
  • 「杂题乱刷」CF1886D
    题目链接简单计数题。容易看出\(<,>\)这两个符号一定只有\(1\)种选择,而\(?\)就有\(i-1\)中选择,总方案数很好推出,这样时间复杂度为\(O(nm)\),不能通过此题,因此我们考虑用逆元优化,优化后时间复杂度\(O(m)\)。参考代码:点击查看代码/*Tips:你数组开小了吗?你MLE了吗?......
  • 杂题选谈
    E.AnotherMinimumSpanningTreehttp://222.180.160.110:1024/contest/4940/problem/5曼哈顿最小距离生成树。题意大概就是,给定\(n\)个已知坐标的点,两两之间可以连边,问最小生成树。「博士,我刚当上秉烛人的时候,花了三个月整,才读完司岁台的所有卷宗,而堆积在您这里的文件,数量......
  • 「杂题乱刷」CF1925C & CF1924A
    题目链接CF1925C&CF1924ADidWeGetEverythingCovered?解题思路容易看出,我们可以开个桶存储当前搜索过的字母,当所有字母都有了之后就将桶清空,然后从当前搜到的位置继续存储,如果桶的清空次数小于\(k\)次则一定有至少一个字符串无法达到要求,这时我们只需要构造桶清空时的......