QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#510171#6979. Awesome Arrowland Adventuretarpent100 ✓1708ms52820kbC++141.5kb2024-08-08 21:53:222024-08-08 21:53:23

Judging History

你现在查看的是最新测评结果

  • [2024-08-08 21:53:23]
  • 评测
  • 测评结果:100
  • 用时:1708ms
  • 内存:52820kb
  • [2024-08-08 21:53:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define p push
const int maxn = 507;
int kr[4]={-1,0,1,0};
int ks[4]={0,1,0,-1};
int n,m;
char c;
int sve[maxn][maxn];
int dji[maxn][maxn];
priority_queue<pair<int,pair<int,int>> ,vector<pair<int,pair<int,int>>> , greater<pair<int,pair<int,int>>>> q;
int main(){
	cin>>n>>m;
	for(int i = 0; i<n; i++){
		for(int j = 0; j<m; j++){
			cin>>c;
			if(c=='X'){
				sve[i][j]=-1;
			}
			else if(c=='N'){
				sve[i][j]=0;
			}
			else if(c=='E'){
				sve[i][j]=1;
			}
			else if(c=='S'){
				sve[i][j]=2;
			}
			else if(c=='W'){
				sve[i][j]=3;
			}
		}
	}
	if(sve[0][0]==-1){
		cout<<-1;
		return 0;
	}
	sve[n-1][m-1]=-2;
	q.p({0,{0,0}});
	pair<int,pair<int,int>> tr;
	bool ch = true;
	while(!q.empty() and ch){
		tr=q.top();
		dji[tr.second.first][tr.second.second]=1;
		if(tr.second.first==n-1 and tr.second.second==m-1){
			cout<<tr.first;
			ch=false;
			break;
		}
		int pr = sve[tr.second.first][tr.second.second];
		//cout<<tr.first<<"     "<<tr.second.first<<' '<<tr.second.second<<"    "<<pr<<endl;
		q.pop();
		for(int i = sve[tr.second.first][tr.second.second]; i<sve[tr.second.first][tr.second.second]+4; i++){
			int r = tr.second.first +kr[i%4];
			int s = tr.second.second + ks[i%4];
			if(r>n-1 or s>m-1 or r<0 or s<0 or dji[r][s]!=0 or sve[r][s]==-1){
				continue;
			}
			else{
				//cout<<i<<"  "<<r<<' '<<s<<endl;
				q.p({tr.first+(i-pr),{r,s}});
			}
		}
	}
	if(ch) cout<<-1;
	
	
	
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 3536kb

input:

1 325
EEEEEEEEEXEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEXEEEXEEEEEXEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEXEEEEEEEEEEEEEEEEEEEXEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEE...

output:

-1

result:

ok single line: '-1'

Test #2:

score: 10
Accepted
time: 0ms
memory: 3540kb

input:

1 232
EEEEEEEEEEEEEXEEEEEEEXEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEX

output:

-1

result:

ok single line: '-1'

Test #3:

score: 10
Accepted
time: 0ms
memory: 3548kb

input:

1 275
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEX

output:

0

result:

ok single line: '0'

Test #4:

score: 10
Accepted
time: 0ms
memory: 3504kb

input:

1 421
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

0

result:

ok single line: '0'

Test #5:

score: 10
Accepted
time: 0ms
memory: 3700kb

input:

1 379
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEE...

output:

-1

result:

ok single line: '-1'

Test #6:

score: 10
Accepted
time: 0ms
memory: 3536kb

input:

1 188
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEX

output:

0

result:

ok single line: '0'

Test #7:

score: 10
Accepted
time: 0ms
memory: 3504kb

input:

1 12
EEXEEEEEEEXX

output:

-1

result:

ok single line: '-1'

Test #8:

score: 10
Accepted
time: 0ms
memory: 3572kb

input:

1 350
EEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

-1

result:

ok single line: '-1'

Test #9:

score: 10
Accepted
time: 0ms
memory: 3552kb

input:

1 435
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEXEEEEEXEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

-1

result:

ok single line: '-1'

Test #10:

score: 10
Accepted
time: 0ms
memory: 3612kb

input:

1 122
EEEXEXEEEEXEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEXEEEEEEEEEEEEEEEXEEEXEEEEEEXXEEEEEEEEEEEEXEEEEX

output:

-1

result:

ok single line: '-1'

Subtask #2:

score: 12
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 12
Accepted
time: 0ms
memory: 3688kb

input:

1 59
XSSWWWNSXNXSSWWESXSENSNXWWENNWEWSNXXNEEWXXENEENXXSNXSXNWWSX

output:

-1

result:

ok single line: '-1'

Test #12:

score: 12
Accepted
time: 0ms
memory: 3700kb

input:

1 319
SWWWSWNSNSWENENWWSSWEEESESWNWSSENEWSEENNNNNWEEEESENWWNWWSSSNSENSNNNWNWESNSSESWWNSNESNSENWWESNNWWESNWSESNSWNSEEWNNNNEESWEEWWNSNSSWNWSWSEENWSWNWSNSEESSWENEEEEWNNNEESNSSWWNWENSWEESWSNENNSNWWSNSWEESENNEEESEEWWESNWSESNNNSEEEWSSNWWSNNWWSNSNWEWEEESWWSSEESSSENEENEEEESSSEEWESNSSWSENWSSNWWWWNESSNENWEEWW...

output:

474

result:

ok single line: '474'

Test #13:

score: 12
Accepted
time: 0ms
memory: 3600kb

input:

1 485
EESENESSSNENSEEESWNEWNWESENESWNNNEENEEWNWSNESWSWWSSNSEESNSWNSSNSSSENWWEEWWWSSEEEENNNWWNNWNWEWWNSSSWNEESWNSWSEEESWSEWEENWWEEEENEEWNNWEWNSEWESSSSNESWEESEEEEEWWNEWSSENSWSSENSESWESNNSWWSNWNWWWSSENESNENWSNWNSEENEEWWNNSSESSSEESSEWNSWEWSNWWWSWWNWWNWWWNWNWESESNSEWESNSWNSSWSENWNEWWSNESNNENWNNNSSESENNSN...

output:

712

result:

ok single line: '712'

Test #14:

score: 12
Accepted
time: 0ms
memory: 3676kb

input:

1 21
WNSNESNWESEENSEWWWENX

output:

27

result:

ok single line: '27'

Test #15:

score: 12
Accepted
time: 0ms
memory: 3676kb

input:

1 173
ENSSEENSEESESNEWEWNWSSESSNSNSESSNNWSSWESEEWSSNESNNWNWNNESENNNNEWNWNWSNSNEWSWSESWSNEWSWNSWESNWNENSESWSNWSWWSNNWSENWEWNEWWNWWSWWNSWSWWEWNSWSSEENWENSNSNEESSNNSENNWSNENWWNNSSWWX

output:

278

result:

ok single line: '278'

Test #16:

score: 12
Accepted
time: 0ms
memory: 3628kb

input:

1 364
SWSNSSENSWWSEWWWWENSEEENNNSEWNNSWSSESENENNNWSNESWWENWEEWWSWNESNEENNWSSWNNSNWESSESSEESSWSWEEWSWNENNSSSSENWSEWWNSSNSEEWNSWEWENSEEWESSSNWSWESNESNSSWNWESEEWNEENESNSWEWEESNNSNSWSSWENWNWWNSWNSWWNWNSNEWNENWNWSESSWNEWNSNNEEESWEWENSSWEWNWSENENESNEWEWSSNSNNWNSSENNWNWSEENEWNWWWSESWWWSSWWEENSEESWWESEWNNSN...

output:

543

result:

ok single line: '543'

Test #17:

score: 12
Accepted
time: 0ms
memory: 3692kb

input:

1 377
ESWSWWWNNEWSWNNNEENWWESSNWNNEESSWNEWSWESSSNEWNENNSWNEENSWESSNWENSSSSNSENNSNNENENEWSEWSSENWNWNWWWNSEEWNNNEWWNWWNWWENNESWESNWEEWWENESSNSWWSENNNESEEWNSEENWSWSEEWESEWENSWSWNSWNSESENSSWNSNSSESENNSSNNWWWNSNWNSSESWWESWWWWNWNWSSWENNSWSENWNNSNNEWEEENNEWNWNWSESNNEWWWESWNESNSESSENWNNWEEWEWSWNSNEESSNNNNWW...

output:

572

result:

ok single line: '572'

Test #18:

score: 12
Accepted
time: 0ms
memory: 3552kb

input:

1 110
NSWWNNSNESSESSSEWSEWWSSNWNNENWNWSWNWSEENSWNESNNSWSEENENSNWSNEWNEWSNSWSNEEESWESSNWSENWNWWSWEWWEESNWSWWSNWNWEWSX

output:

177

result:

ok single line: '177'

Test #19:

score: 12
Accepted
time: 0ms
memory: 3620kb

input:

1 150
EWESNWSWSSSNEEWSNEWNSWNWENWNWEWSWSNNNNSWNNSWSWENWSEENWSENEWWESSESWNSNWEEWSEEEEWWNEEENWNNNENNNEESNESENNNEEEESSSSSEWWWSWNEENNESWWESNNNWWWESESNWEWENNSWSX

output:

210

result:

ok single line: '210'

Test #20:

score: 12
Accepted
time: 0ms
memory: 3696kb

input:

1 471
WESESENEWENSSESSNNNNSEWSNWSSWESEEWEEENSSESEENNWSWSNWWESWSNNNESNSSSWWNEEWEENESWWSNNNSWNNENNNWEENESSSWNENWWWSNWWNWNSNEEWEWEESSSNWNWSWENWWWNEESENSEEWNWENWNSEENNWWWEWWSWENWWENNSWSEENESSNSSSSWSSSENNESSWWENNENENNWENSWSSWNNNSWESSWSESWSSSNWSSWNNNNEEESWSWWWWSNWWEWESSNEENNWSSSENNWSNWWENNSESSSSEWSSSEWSES...

output:

725

result:

ok single line: '725'

Subtask #3:

score: 12
Accepted

Test #21:

score: 12
Accepted
time: 0ms
memory: 3620kb

input:

3 3
SNX
SEE
XXX

output:

4

result:

ok single line: '4'

Test #22:

score: 12
Accepted
time: 0ms
memory: 3696kb

input:

3 3
EWE
SNN
WXX

output:

5

result:

ok single line: '5'

Test #23:

score: 12
Accepted
time: 0ms
memory: 3552kb

input:

3 3
WXE
XXN
SWX

output:

-1

result:

ok single line: '-1'

Test #24:

score: 12
Accepted
time: 0ms
memory: 3700kb

input:

3 3
XSW
SSX
WWX

output:

-1

result:

ok single line: '-1'

Subtask #4:

score: 16
Accepted

Test #25:

score: 16
Accepted
time: 0ms
memory: 3696kb

input:

2 496
WSXWWESEEXWXXWXESWNENEEWXEXNENXESEEWSENXSWSSNSWSXESSXEXWNEXWWNEESSNSXSNSESESNWWEXNWXNNEEWWXWXXEWNENXXWEEWWXXEWEWXEEEENSNXNEEEWSEEEWSEWSWXSEXSWXSXESWNWXXXXENNWNEWSWSSWSXNXXEWXEXNESNEWSXSNSEWWSNSSENNXSNNWXSSNXNWXXSNXSNSSXEESEESSWNXNNWSSNSSWSEEEWNXXWSEEEWENSWXNXXSENXWNSENSXXSNEXXWSXXXEEEENNNNEWNX...

output:

-1

result:

ok single line: '-1'

Test #26:

score: 16
Accepted
time: 0ms
memory: 3640kb

input:

2 57
SWEESSSENESWENWESNWWWWESNSWNWWSSSSESNNWNNENENENEESSSENNWN
ENNSESEWWNNEWSSWWESNENEEWSENEEWENNESEWNENWNSNEWNNEEESNEEX

output:

42

result:

ok single line: '42'

Test #27:

score: 16
Accepted
time: 1ms
memory: 3620kb

input:

2 219
NESNWSEEEEEWNNNNSNENWSESESNSWSNWWSNNENWWSSESNENENNNENEWSENNSNNESEEESEEEENNNSWSNENSESNNWNSSSWNNNNSSNSEESENWNWNSWSEWNNNNSESESSWNESWENSSWESNWNNWSWENSEWSWSWSWSWEWESNENENENWNWNWWEWEWEWSSNENWSEWNWEWWSSEWWEWWSNSWWEWEWWNNEWESNS
SSSSSSSSSSNSNNNSWWSSWEWWSSENNWNNNNNWWNNENEWWNNWSWENSEWSNENWEEEESENNSNWSSWE...

output:

229

result:

ok single line: '229'

Test #28:

score: 16
Accepted
time: 1ms
memory: 3636kb

input:

2 167
WESNSESWWEWWNSEENNSSWEWEEWWNNSSSESSSNENWENEWESSSWWSESENWNWNNWWSSNNSWWNNNEEENNSEWNESNWSSSSWWNWENWSSWNWNSENSSWNEWENSWESWESWNENWWNENNSENWNNEWENENNNSSSNSSNEWESWNNWENNEWWSE
WEEEEESWEEWWWSNSNENWEEESWNSNNNWENNSNSSSSSSEESNWENNEWWNSSNWEWESNESSSWWSWSNNSSEEESWSNSWSNWSWSNNNEWEWWEEWSNSNSNWEEEWEEWNESSWSESWW...

output:

189

result:

ok single line: '189'

Test #29:

score: 16
Accepted
time: 1708ms
memory: 52820kb

input:

2 423
WNWESNSWSSEENWSNSEESENESNNWNNSNNNEEWSSWWSWSWSSEWWSEESSNEWSSSWENNENEESSSSWWSEWSSWNWNWSSNESSEWSWNSNENNEWWSNENSWNEEENESWWNNENWEWNNSWNEENWSENSEWNESNNEESNENENNWSWNNNSEENWENWEWSSSESEWWSWWWWNWWNWNESSESWEWWSNNWWNNSSNSESENENWNESEENSWNESSESSNNNSNSSWEEWNSNSNSNNSENWNSENESNEWNSESNSESNNSEWESSESEWNNSNWWWESWS...

output:

500

result:

ok single line: '500'

Test #30:

score: 16
Accepted
time: 1ms
memory: 3596kb

input:

2 367
NWSSSWWSSSNWEWSEWNEENSWEEESESSSSEEENNEEWNWNNNWSEWESWNENNEWNSWESSSWNWNWWNWEEESEEWSEWSNEWWSSEENSWESNSWNNWNESSNNWWWNNNWENNSESSWENSNNSSEEWEWEESNEEWEEEWENWNWSWWNSENSWSSENENENWWENNWWNWWSEEENESEEENWNWENEWSWSEENSESEWNEEWWSWSNEWWWSWNWWESSESWNSSWSSSWEWEWEEWEEWENSSEWWNEWNENESNEEWNNNWWEWWENNNSNEEWWWNSNWWW...

output:

426

result:

ok single line: '426'

Test #31:

score: 16
Accepted
time: 0ms
memory: 3620kb

input:

2 175
WENNENSSNNSWENWWSWSWNENWWWNSEWSWEWWNNWNSWWSWNNSWWWSEEESWNEESSWWEESWEENNWSSSWSNNWEESESESSWSNWEWSNEWWNWNSSWWNENWEEENWNWNNWWWWSNNENWSNNENWENNWNWWWWSWNSEWENWWEEWEWSEWENNNESNNWNNSS
NEWSSSESWNWESSNSSNSSWESWWENNSEENNSSWSNENWNNSNESENNNEEWEWSEWSWWNSEESSSSSNSEEWSSWSNSENNWWWEWNSESNESNEEEWNNEWNSWNWWEEEWWE...

output:

200

result:

ok single line: '200'

Test #32:

score: 16
Accepted
time: 0ms
memory: 3676kb

input:

2 66
NEWENNWSWEWWESNWEEWWNNNWWENENSESENWWNEWENENSSENSNSEWWWEEWNNSEENEES
EEENSNESWEENESSSNWSNWNEWSWSWSSSNEENWSSSESNWNWWWWNENEWWSWSNSNWEWEWX

output:

66

result:

ok single line: '66'

Test #33:

score: 16
Accepted
time: 0ms
memory: 3508kb

input:

2 68
NWSNWNWEEESNSNSNENWENSWWSWSWNNNWWWWENEENNENEENEESSESWSNSNNSSNNSWSWNW
WSNNSSSEENESWSEWNSESSEWEEWWENENEENNWWESSEENSWSNNNSENENNSSWEWSNNWNWNX

output:

64

result:

ok single line: '64'

Test #34:

score: 16
Accepted
time: 0ms
memory: 3616kb

input:

2 56
EWWNNEESNWNSWEWSENNWNNSESSNSWWNSNWWENEWNWNSNNNNEWWWSWNEN
SSSWWEESNWSEWSNNSESSEEWSWSWEWENNWEWNEEEWWWWWNEEWSWWWEEWX

output:

67

result:

ok single line: '67'

Subtask #5:

score: 50
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #35:

score: 50
Accepted
time: 12ms
memory: 3796kb

input:

56 409
SEXWWWSEWWEESSWNNXNSESSWXXWESSWWSEWEWWXEXWEWWXESNXSXSWSEEXEXSXSWSEWWNSEEWNSWXENEXXSNNXNWXWSXWXNENSWNNSNNEWENENSNESWWWEXSWESNXXEWSENSSWSNSEWNXEXWSNWSXSWEXNEWEWSWWWWWNNWNXSXEENSSEEXEWXNENXWXSSWSXXXESXEXXNSXXXEWNENSSXNEENWNNNNNXWWWSXESXEWENXEXSNNSSXSWSSNWEEWXSNSEXNXSWNNNWESXWEWXXXWEXEWNXXENWEEXE...

output:

-1

result:

ok single line: '-1'

Test #36:

score: 50
Accepted
time: 0ms
memory: 3688kb

input:

7 326
XWESWNENNNNEEESEEXNSXESXSNXWWXXSESNENESEXWNEXNWENSNXWWENXXNWWXXSEXXESESXEEEWXENESNNNEWXWWSXWXXSSESNXXNSNEWEESXXSEXXEEWNXEWXESWSXXWSSSNEWXNEWWWNNNSSWXXNEEWNNEWNXXNSWNNSSWXEENEEXNNWXWNSWNXWWSXSSESEENNESWWSNEEXWEESENWXWNXXSNEXWWNXWNXWWSXWSNSNSXEWXXWEEWSSWNWESXEXSWXNNXEEWSSXWSXSWXXEWSESWSSSXWXNWXN...

output:

-1

result:

ok single line: '-1'

Test #37:

score: 50
Accepted
time: 21ms
memory: 4228kb

input:

105 255
WNESEENEWXNSNEWEEEXENXSSXXNWNWESXSWEESWNSSSENXXNEENSWENXWEXNNSEWWWXSNENWNXXXWEWWESEWSNEEWSWNNNEEESESNSXNXWENNWSSWXEENXWWNSXENNSWSWWXSESWSSENWWSXNWSNSXSSXSWNXXSWEESSSXXNNXSEXNWWNSXNNSWNESXWSNEXNNXENSXSNESXXWEEWWSNNEEXWXXSEESSWNSXNSXEWEWWXEXWESESSNSXESSWSWS
EXXXXXWENXSSXSWXNNXWXSXENSWXSSNEWNNN...

output:

260

result:

ok single line: '260'

Test #38:

score: 50
Accepted
time: 0ms
memory: 4216kb

input:

264 156
XSNESSWSWWESEWSEWXXNNNWNWWXEXEWWNEEWXWXXSEWEENEEWWENEXWWESXEXNWNESWNWEXSXXXNENWEWSNNWWSNWEXSWXSNWNEEWEWXWEWWWWEWWSWSXWXSXXWNEWWESENWNSWNXWENXXXNSWEEEENSNNEX
XXNSXESNENEEXXXNNWSNXNWWNEWSWXENEEEESSNNEEWXNXWEWXNNSESEWNXWSEXEWSXNENESNWEEXSWEEWNNWXSNESWXSNSWXWWWNXXEXXSXSSEXWWSEXSSWSNSSSEENNSWNWNN...

output:

-1

result:

ok single line: '-1'

Test #39:

score: 50
Accepted
time: 339ms
memory: 6808kb

input:

500 500
NEWXESESNXNWNNWEWWSNEXWNWXEEEXSWNEENSESESNSWXEWXSSXNNSSXSWENWWEENXSSWXSSSWNSSEWSSENNWNSWSWXXSXXWWXENSWNWNWNNNXNNNXSWWNSSXSSSEWNXNSNWWWNEESXSWWENENEXESNEEWSESESXXNWEEEEEXNWWWSNWEWENXWXSENENNWSXWSWSWESNEXXENNWNXENWWNNXEXXWSWNNENNXEXEEWESENEXWNXNEWSSXXSEXWNXSENEWSWWSEXWENSEEWESNXSEENWEEWSENSSSX...

output:

668

result:

ok single line: '668'

Test #40:

score: 50
Accepted
time: 332ms
memory: 6484kb

input:

500 500
SSWEXWESXWSNEXXSSXSNWWNXEWWNNSSWXXEXXSWXWWENENENEXSESWEWXWWWNSWEXSESESEWNNWWNXWEESXSWENWXWNSXNENNNEWSENSXNSWNNNSEWNENNXSNESSENWESWXWEEEEEENXXWXNEXNSSEEWWWWSSWXWEXSXXESWXSSESNNWEXSWWNSXWSEXSEXXNXWNSSWXNXSNNXSESENXSNNSESNESXXXWNWXXENXNNWXWEWWWNEXSNNNXXWEWWSSENSXXNWESXESXNXXXXXXNWXSWESSENWNXWWX...

output:

697

result:

ok single line: '697'

Test #41:

score: 50
Accepted
time: 8ms
memory: 4532kb

input:

500 500
WXNSXXXWEWXEWNSXWNEESSSNSXSXENWWXXNXNSWXWEEWWSSSXXXSXESWSNWSXWSEXENEEWENSXSXXENWNWNSSSNESEENWSEENXNENWSXEEWWXXWWSNSNNXNESSEESESXNEXNENEWSSWENEXEESENNWENWSEWNWWWXWWXXSNSSNESWXNWSXENNXWSENSSEXSNNNXWNNSNENXSNEWEEWXWENNXSENEXESNSENSSNENXWWXWEWNEENNWXNENWEESXEXENSWSEWSESSWSNWSXEENSSXXESENXXENNENW...

output:

-1

result:

ok single line: '-1'

Test #42:

score: 50
Accepted
time: 299ms
memory: 6528kb

input:

500 500
NEXWEXNNWWWXSNXEXEEEXSSSSEWSSSSEWNSNWXWNEWSSSWWEWSNWEENWENENNEWSSXXXXNSESSSEXNNEXXSNNEWNSEXNWXSSXNNXEWXWNSWSXNNSWWSSWXXXSNSSNNEWENWXEXESSXWXSWNSNSSNWEEXSXNNWWSNNXWWSSENXNWSXXENEWEEXXWESSWEWENXWWEEXSWXWWENNESWWSNXESNSEXNNSEWNNWWNSWWWWWXNEEEXNSWEENNNWXEWXWEWWNWEEXWSENXNNNNNWENWXXNNWSSEWEXNNSNS...

output:

700

result:

ok single line: '700'

Test #43:

score: 50
Accepted
time: 39ms
memory: 8192kb

input:

499 499
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

0

result:

ok single line: '0'

Test #44:

score: 50
Accepted
time: 12ms
memory: 4496kb

input:

500 500
XWSXEEXWWSNSWWEENSEXENNNSESSNXXEXSXNSNWXWXXNWNXNSNSEXENXSWXEXWNNWEXEXXEEXNESEESXEWENSSWWWNWWWWXSWXXNSESEWSNENSNSWESEXENXWWSSSSXWXNWEWWWXXWENEXWXWNNSESENNESSNSSXXXEEXSSEEWWXNXNSSXSWSWNENEENNWWWWNSXWNXWNXSSXSNXWWENXWWXXNSSSSWSSWSXSNSSNENSSWNESEWNSWSSWESWEXXWSXNEENSWSEXWWXSWXEWNXWEESNEEXSSXNEEE...

output:

-1

result:

ok single line: '-1'