[Offer收割]编程练习赛12 register

Ended

Participants:1323

Verdict:Accepted
Score:100 / 100
Submitted:2017-04-02 12:54:05

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 105;
int f[maxn][maxn][4];
int n,m;
char s[maxn][maxn];
struct P{
  int x,y,z;
  P(){};
  P(int x,int y,int z):x(x),y(y),z(z){}
};
vector<P> routeHelper(int x,int y,int z){
  vector<P> ret;
  int nz=(z+2)%4;
  int nx=(z&1)?x+(z==3?1:-1):x;
  int ny=(z&1)?y:(z==0?1:-1)+y;
  if(nx>=0&&nx<n&&ny>=0&&ny<m)ret.push_back(P(nx,ny,nz));
  if(s[x][y]==' '||(s[x][y]=='\\'&&!(z&1))||(s[x][y]=='\/'&&(z&1)))
  ret.push_back(P(x,y,(z+1)%4));
  if(s[x][y]==' '||(s[x][y]=='\\'&&(z&1))||(s[x][y]=='\/'&&!(z&1)))
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX