我的 code:
#include<bits/stdc++.h>
#define int long long
#define fore(i,x,n) for(int i=x;i<=n;i++)
using namespace std;
const int MAXX=200005;
const int mod=1;
inline int read(){
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
signed main(){
int a,b,f;
char c;
a=read();b=read();
cin>>c;
f=read();
if(f!=0){
fore(i,1,a){
fore(j,1,b){
putchar(c);
}
putchar('\n');
}
}
else{
fore(i,1,a){
fore(j,1,b){
if(j!=1&&j!=b&&i!=1&&i!=a){
putchar(' ');
}
else putchar(c);
}
putchar('\n');
}
}
}
試過最大的數據,用時 23 ms。
但交上去除了 #3 #4 #6 #7 AC 了其他全部 TLE。
請問有啥數據能讓這個代碼超時的。
時間複雜度 O(ab) 應該可以過啊?