QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#813605 | #9884. Grid Construction | ucup-team1004# | RE | 0ms | 4068kb | C++20 | 2.1kb | 2024-12-14 10:55:10 | 2024-12-14 10:55:10 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e3+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,m;
char ans[N][N];
void construct(int n,int sx,int sy){
for(int i=1;i<n;i++){
ans[sx][sy+i-1]='<';
ans[sx+n-1][sy+i]='>';
ans[sx+i][sy]='v';
ans[sx+i-1][sy+n-1]='^';
}
if(n<=3){
if(n==3) ans[sx+1][sy+1]='.';
return;
}
for(int i=3;i<n;i+=2){
ans[sx+1][sy+i-1]='v';
ans[sx+n-1-1][sy+i-1]='^';
ans[sx+i-1][sy+1]='>';
ans[sx+i-1][sy+n-2]='<';
}
for(int i=4;i<n-2;i+=2){
ans[sx+2][sy+i-1]='^';
ans[sx+n-3][sy+i-1]='v';
ans[sx+i-1][sy+2]='<';
ans[sx+i-1][sy+n-3]='>';
}
construct(n-6,sx+3,sy+3);
}
void Solve(){
for(int x:{0,1,2}) for(int y:{0,1,2}) if((x*(y+1)+y*(x+1))%3==0) gdb(x,y);
scanf("%d%d",&n,&m);
if(n%3==1){
puts("No");
return;
}
if(n%3==0&&n%2==0){
puts("No");
return;
}
if(n%3==2&&n%2==0&&n>2){
puts("No");
return;
}
if(n^m){
assert(0);
puts("No");
return;
}
puts("Yes");
for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) ans[i][j]='.';
construct(n,1,1);
for(int i=1;i<=n;i++) printf("%s\n",ans[i]+1);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4068kb
input:
3 3
output:
Yes <<^ v.^ v>>
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3996kb
input:
4 4
output:
No
result:
ok Correct : No
Test #3:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
4 5
output:
No
result:
ok Correct : No
Test #4:
score: -100
Runtime Error
input:
11 17