版本比较
模拟赛四道题题解
正文
增加 5 行删除 5 行
15 行未改动1617181920202122232491 行未改动11611711811912012012112212312466 行未改动1911921931941951951961971981992002012002012022032042059 行未改动15 行未改动```cpp#include <bits/stdc++.h>using namespace std;string s; int N, cnt;int main() 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的概率为1 dp[0][0] = 1; //还没做题时总分对m的余数为0的概率为1 for(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++) //尝试行走 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]; //tree else if(s[nx][ny] == '#') continue; //墙 if(nc < dis[nx][ny]) //最小代价 else if(s[nx][ny] == '#') continue; //墙 if(nc < dis[nx][ny]) //最小代价 { dis[nx][ny] = nc; q.push({nc, {nx, ny}}); }9 行未改动