TLE on #9,但是下载下来的样例3ms可过,思路就是tj-1
  • 板块P1229 遍历问题
  • 楼主紊莫turtle
  • 当前回复4
  • 已保存回复4
  • 发布时间2022/6/9 11:39
  • 上次更新2023/10/27 23:41:33
查看原帖
TLE on #9,但是下载下来的样例3ms可过,思路就是tj-1
443675
紊莫turtle楼主2022/6/9 11:39

RT,用了第一篇tj的思路,比较迷惑。 90pts 代码:(和long long 无关,试过去掉了)

#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){if (x < 0) x = ~x + 1, putchar('-');if (x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(int x){write(x);putchar('\n');}
inline void writesp(int x){write(x);putchar(' ');}
inline string sread(){string str="";char ch=getchar();while(ch==' ' || ch=='\n' || ch=='\r')ch=getchar(); while(ch!=' ' && ch!='\n' && ch!='\r'){str+=ch;ch=getchar();} return str;}
signed main()
{
//	double st=clock();
	string s1=sread(),s2=sread();
//	string s1="edbjkacfghi",s2="jkbchigfade";
	int k=0;
	for(int i=0;i<s1.length();i++)
		for(int j=0;j<s2.length();j++)
			k+=s1[i]==s2[j+1]&&s1[i+1]==s2[j];
	write(1<<k);
//	double ed=clock();
//	printf("Used: %.0lfms",ed-st);
	return 0;
}

注释的是调试代码,样例就在里面。

2022/6/9 11:39
加载中...