跳到正文

个人记录

10.3模拟

lyx_X2026约 3 分钟
原文
文章信息与版本

文章信息

发布
2026年10月3日
收录
2026年10月4日
更新
2026年11月14日
篇幅
约 3 分钟

版本

  1. v1当前

T1

题目
AC代码
C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("restore.in","r",stdin);
	freopen("restore.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		int k=n;
		for(int i=0,j=n-1;i<k/2;i++,j--){
			if(s[i]!=s[j]) n-=2;
			else break;
		}
		cout<<n<<'\n';
	}
	return 0;
}

T2

题目
WA代码
C++
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[4][N];
int dp[4][N];
int n;
int main()
{
	freopen("study.in","r",stdin);
	freopen("study.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[0][i];
	for(int i=1;i<=n;i++) cin>>a[1][i];
	for(int i=1;i<=n;i++) cin>>a[2][i];
	for(int i=n;i>=1;i--){
		for(int j=0;j<3;j++){
			dp[j][i]=a[j][i]+min(dp[(j+2)%3][i+1],dp[(j+4)%3][i+1]);
		}
	}
    for(int i=0;i<3;i++){
        for(int j=1;j<=n;j++){
            cout<<dp[i][j]<<' ';
        }
        cout<'\n';
    }
	cout<<min(dp[0][1],min(dp[1][1],dp[2][1]));
	return 0;
}
错因

第2323~2828行是比赛时的调试!忘删了!!!
T^T

原文