版本比较
AtCoder Beginner Contest 436 Solutions
正文
增加 5 行删除 5 行
59 行未改动60616263646465666768686970717277 行未改动15015115215315415415515615715837 行未改动19619719819920020020120220320414 行未改动21922022122222322322422522622722859 行未改动 a[r][c] = 1;
for(int i=2; i <= n*n; i++) { if(!a[(r - 1 + n) % n][(c + 1) % n]) if(!a[(r - 1 + n) % n][(c + 1) % n]) r = (r - 1 + n) % n, c = (c + 1) % n, a[r][c] = i; else else r = (r + 1) % n, a[r][c] = i; }
77 行未改动 ans ++; } } cout << ans;
return 0;}```
37 行未改动 for(int i=1; i<=h; i++) for(int j=1; j<=w; j++) { cin >> s[i][j]; if(s[i][j] != '#' && s[i][j] != '.') if(s[i][j] != '#' && s[i][j] != '.') siu[s[i][j] - 'a'].push_back({i, j, 0}); }
queue<Edge> q; int ans = 0;14 行未改动 int dx = t.x + r[i][0]; int dy = t.y + r[i][1]; if(vis[dx][dy] == 0 && dx >= 1 && dx <= h && dy >= 1 && dy <= w && s[dx][dy] != '#') q.push({dx, dy, t.st + 1}), vis[dx][dy] = 1; } } } cout << (ans ? ans : -1) << endl; return 0;}```