正文
增加 5 行删除 5 行
15 行未改动16171819202122232491 行未改动11611711811912012112212312466 行未改动1911921931941951961971981992002012022032042059 行未改动15 行未改动```cpp#include <bits/stdc++.h>using namespace std;string s; int N, cnt;int main(){cin >> N >> s; cnt = 0;int st[5] = {0};for(char ch : s)91 行未改动ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);cin >> n >> m;for(int i=1; i<=n; i++) {cin >> a[i]; a[i] %= m;}for(int i=1; i<=n; i++) cin >> p[i];dp[0][0] = 1; //还没做题时总分对m的余数为0的概率为1for(int i=1; i<=n; i++){tot ^= 1; //if(tot=0) tot=1; else tot=0;for(int j=0; j<m; j++) dp[j][tot] = 0;66 行未改动{auto [c, xy] = q.top(); q.pop();int x = xy.first, y = xy.second;if(c != dis[x][y]) continue;for(int d=0; d<4; d++) //尝试行走{int nx = x + dx[d], ny = y + dy[d]; ll nc = c;if(nx < 1 || nx > n || ny < 1 || ny > m) continue;if(tr[nx][ny] > 0) nc += tr[nx][ny]; //treeelse if(s[nx][ny] == '#') continue; //墙if(nc < dis[nx][ny]) //最小代价{dis[nx][ny] = nc;q.push({nc, {nx, ny}});}9 行未改动15 行未改动16171819202122232491 行未改动11611711811912012112212312466 行未改动1911921931941951961971981992002012022032042059 行未改动15 行未改动```cpp#include <bits/stdc++.h>using namespace std;string s; int N, cnt;int main(){cin >> N >> s; cnt = 0;int st[5] = {0};for(char ch : s)91 行未改动ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);cin >> n >> m;for(int i=1; i<=n; i++) {cin >> a[i]; a[i] %= m;}for(int i=1; i<=n; i++) cin >> p[i];dp[0][0] = 1; //还没做题时总分对m的余数为0的概率为1for(int i=1; i<=n; i++){tot ^= 1; //if(tot=0) tot=1; else tot=0;for(int j=0; j<m; j++) dp[j][tot] = 0;66 行未改动{auto [c, xy] = q.top(); q.pop();int x = xy.first, y = xy.second;if(c != dis[x][y]) continue;for(int d=0; d<4; d++) //尝试行走{int nx = x + dx[d], ny = y + dy[d]; ll nc = c;if(nx < 1 || nx > n || ny < 1 || ny > m) continue;if(tr[nx][ny] > 0) nc += tr[nx][ny]; //treeelse if(s[nx][ny] == '#') continue; //墙if(nc < dis[nx][ny]) //最小代价{dis[nx][ny] = nc;q.push({nc, {nx, ny}});}9 行未改动