版本比较
题解:CF2044H Hard Demon Problem
正文
增加 2 行删除 2 行
31 行未改动323334353636373839402 行未改动434445464747484950515231 行未改动 si[i][j] = si[i - 1][j] + si[i][j - 1] - si[i - 1][j - 1] + x * i; sj[i][j] = sj[i - 1][j] + sj[i][j - 1] - sj[i - 1][j - 1] + x * j; } }
while(q--){ int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; ll s1 = s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];2 行未改动 s2 *= (y2 - y1 + 1); s1 *= (x1 * (y2 - y1 + 1) + y1 - 1); cout << s2 + s3 - s1 << ' '; }
cout << '\n'; } return 0;}```