Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:样例过了但一直WA,求大神帮忙看看

Posted by KJJD at 2023-07-14 19:47:58 on Problem 2488
In Reply To:样例过了但一直WA,求大神帮忙看看 Posted by:han13 at 2023-07-11 21:40:45
> #include<iostream>
> #include<algorithm>
> #include<cstring>
> #include<queue>
> #include<vector>
> #define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
> #define endl "\n"
> using namespace std;
> typedef long long ll;  
> int vis[30][30];
> int n,m;
> int step;
> bool flag;
> vector<char>s;
> void DFS(int x, int y, int sum)
> {
>     if(sum==n*m) {
>         flag=1;
>         return ;
>     }
>     vis[0][0]=1;
>     
>     int dx[8]={-1,1,-2,2,-2,2,-1,1}, dy[8]={-2,-2,-1,-1,1,1,2,2};
>     for(int i=0;i<8;i++) {
>         int xx=x+dx[i], yy=y+dy[i];
>         if(xx>=0&&xx<n&&yy>=0&&yy<m&&!vis[xx][yy]) {
>             vis[xx][yy]=1; 
>             s.push_back(char(xx+'A'));
>             s.push_back(char(yy+'1'));
>             DFS(xx,yy,sum+1);
>             if(flag) return ;
>             vis[xx][yy]=0;
>             s.erase(s.end()-1);
>             s.erase(s.end()-1);
>         }
>     }
>     flag=0;
>     return ;
> }
> int main()
> {
>     FAST;
>     int t;
>     cin>>t;
>     
>     for(int i=1;i<=t;i++)
>     {
>         s.clear();
>         memset(vis,0,sizeof(vis));
>         s.push_back('A');
>         s.push_back('1');
>         flag=0;
>         step=0;
>         cin>>m>>n;
>         cout<<"Scenario #"<<i<<":"<<endl;
>         DFS(0,0,1);
>         if(flag) {
>             for(int i=0;i<s.size();i++) cout<<s[i];
>             cout<<endl;
>         }
>         else cout<<"impossible"<<endl;
>         cout<<endl;
>     }
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator