| | Knight can't step on the cell with the horned demonI've already run throw every test i've found here and some that I thpught myself.I dont understand what is test #23.
 Can someone post some test to run?
 
 Edited by author 08.03.2021 04:25
 
 Edited by author 25.03.2021 12:41
Input3 3 1
 1 1
 3 3
 Output
 0
 is it correct?
 I think so. My AC solution outputs 0.
 It should be noted that the problem statement doesn't mention what happens if you can't get next to the demon in at most L moves. Either such a test is invalid or you should output 0, since you can't stike it, thus you give it a stike of at most 0 intensity.
Here's my code-
 #include <bits/stdc++.h>
 using namespace std;
 
 bool upp,downn,leftt,rightt,avleftt,avrightt,avupp,avdownn;
 
 
 bool vis[105][105],vis2[105][105];
 int dist[105][105];
 int dist2[105][105];
 int xmov[4]={0,-1,0,1};
 int ymov[4]={-1,0,1,0};
 int main()
 {
 // cout << "Hello World!" << endl;
 ios::sync_with_stdio(false);
 for(int i=1;i<105;i++)for(int j=1;j<105;j++)dist[i][j]=INT_MAX;
 int n,m,l,x1,y1,x2,y2;
 cin>>n>>m>>l;
 cin>>x1>>y1;
 cin>>x2>>y2;
 
 queue <pair <int,int> > q;
 queue <int> distt;
 int ans=0;
 if(abs(x1-x2)+abs(y1-y2)==1){
 ans=1;
 }
 vis[x1][y1]=true;
 dist[x1][y1]=0;
 vis[x2][y2]=true;
 q.push(make_pair(x1,y1));
 distt.push(0);
 
 
 while(q.empty()==0){
 pair <int,int> topp=q.front();
 int curdist=distt.front();
 q.pop();
 distt.pop();
 int curx,cury,nextx,nexty;
 curx=topp.first;
 cury=topp.second;
 for(int i=0;i<4;i++){
 nextx=curx+xmov[i];
 nexty=cury+ymov[i];
 if(nextx>=1&&nextx<=n&&nexty>=1&&nexty<=m){
 
 if(vis[nextx][nexty]==false){
 vis[nextx][nexty]=true;
 q.push(make_pair(nextx,nexty));
 distt.push(curdist+1);
 dist[nextx][nexty]=curdist+1;
 }
 }
 }
 }
 
 
 q.push(make_pair(x2,y2));
 distt.push(-1);
 vis2[x2][y2]=true;
 dist2[x2][y1]=-1;
 while(q.empty()==0){
 pair <int,int> topp=q.front();
 int curdist=distt.front();
 q.pop();
 distt.pop();
 int curx,cury,nextx,nexty;
 curx=topp.first;
 cury=topp.second;
 for(int i=0;i<4;i++){
 nextx=curx+xmov[i];
 nexty=cury+ymov[i];
 if(nextx>=1&&nextx<=n&&nexty>=1&&nexty<=m){
 
 if(vis2[nextx][nexty]==false){
 vis2[nextx][nexty]=true;
 q.push(make_pair(nextx,nexty));
 distt.push(curdist+1);
 dist2[nextx][nexty]=curdist+1;
 }
 }
 }
 }
 
 for(int i=1;i<=n;i++){
 for(int j=1;j<=m;j++){
 if(i==x2&&j==y2){
 continue;
 }
 
 if(dist[i][j]!=INT_MAX){
 cout<<i<<" ::::: "<<j<<"\n";
 int totaldist=dist[i][j]+dist2[i][j];
 if(totaldist<=l){
 ans=max(ans,max(abs(y2-j),abs(x2-i))+1);
 }
 }
 
 }
 }
 
 cout<<ans;
 return 0;
 }
Can the knight run back and forward on the segment? Does it count as run up?
 Example:
 
 The monster is at (1,3), the knight is at (1,1)
 
 If the knight does
 (1,1) -> (1,2) -> (1,1) -> (1,2) -> Strike
 the strike force is 4 or 2?
 
 Thanks in advance
please give test case!i checked all test case which came to my mind.
 thanks
 Try this. I used my AC6 1 8
 6 1
 5 1
 ans 1
 6 1 6
 4 1
 5 1
 ans 4
 6 2 8
 6 2
 5 2
 ans 4
 6 2 10
 6 2
 5 2
 ans 5
 Thanks a lot. I forgot about singular cases and had WA #13.why6 1 6
 4 1
 5 1
 ans 4?
 we go to the cell(1,1) (3 moves) and then to the cell(4,1) (3 moves) and hit. k=4 so ans is 5. what's wrong?
 
 Edited by author 01.04.2010 02:00
 hit is not a step. 3 steps to adjacent cell with monster Then why the answer for the sample test3 4 4
 1 1
 3 4
 is 4 ??
 According with your explanation it should be 3, instead 4
 Easy problem but difficult language !!
 Sorry, it was my mistake, your explanation is correctPlease, gimme some tests equal test8
 Edited by author 08.01.2010 02:59
now i  have AC!
 Edited by author 25.05.2009 11:45
Thanks. try3 3 2
 1 1
 3 3
 Answer 0
 Some tricky... I had WA3 when I used 'l' as temporary variable for one of the loopsPlease, give me some tests on #21 Please, give me some examples! I don't now why I get WA on test #21... try this test
 5 7 10
 2 2
 3 7
 
 Ans: 7.
I understood my mistake
 Edited by author 19.10.2006 02:40
 | 
 |