版本比较
USACO26JAN2
正文
增加 5 行删除 5 行
40 行未改动41424344454647484968 行未改动11811912012112212312412512620 行未改动1471481491501511521531541552 行未改动15815916016116216316416516658 行未改动22522622722822923023140 行未改动a[i] = rd(), b[i] = rd(), c[i] = rd();if(b[i] > c[i]) swap(b[i], c[i]);cx[a[i]][b[i]][c[i]]++;}for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++)for(int k = 1; k <= n; k++) if(cx[i][j][k]) {int t = N ^ (1 << (i - 1)) ^ (1 << (j - 1)) ^ (1 << (k - 1));for(int s = t; ; s = t & (s - 1)) {f[s | (1 << (i - 1))] += cx[i][j][k];68 行未改动int len = cx[2].size();if(cx[2].size() != cx[3].size()) return 1;if(cx[0].size() && cx[1].size() && !cx[2].size()) return 1;string res;for(int v : cx[0]) ans.push_back(v), res += 'J';if(len) ans.push_back(cx[2][0]), res += 'J';int now = 1;for(int v : cx[1]) ans.push_back(v), now ^= 1, res += (now ? 'J' : 'N');if(len) ans.push_back(cx[3][0]), now ^= 1, res += (now ? 'J' : 'N');20 行未改动```cppll n = rd(), c = rd(), ans = 0;for(ll i = 1; i <= c; i++) a[i] = rd();for(ll i = 1; i <= n; i++) p[i] = rd();for(ll i = 1; i <= n; i++)for(ll Q = rd(), x; Q--; ) x = rd(), cx[x].push_back(i);for(ll i = 1; i <= c; i++) {while(now[i] < cx[i].size() && a[i]) {ll x = cx[i][now[i]];2 行未改动}}cout << ans << '\n';for(ll i = 1; i < n; i++) {ll t = p[i], id = f[t];if(f[t]) ans -= t;vis[t] = 1;while(now[id] < cx[id].size()) {ll x = cx[id][now[id]];58 行未改动p[(i - 1) % n + 1] = f[q[l]] - 2 * q[l] + i;while(l <= r && f[q[r]] - 2 * q[r] > f[i] - 2 * i) r--;q[++r] = i;}for(int i = 1; i <= n; i++)cout << min(min(f[i] - i, n + i - g[i]), min(h[i], p[i])) << " \n"[i == n];```40 行未改动41424344454647484968 行未改动11811912012112212312412512620 行未改动1471481491501511521531541552 行未改动15815916016116216316416516658 行未改动22522622722822923023140 行未改动a[i] = rd(), b[i] = rd(), c[i] = rd();if(b[i] > c[i]) swap(b[i], c[i]);cx[a[i]][b[i]][c[i]]++;}for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++)for(int k = 1; k <= n; k++) if(cx[i][j][k]) {int t = N ^ (1 << (i - 1)) ^ (1 << (j - 1)) ^ (1 << (k - 1));for(int s = t; ; s = t & (s - 1)) {f[s | (1 << (i - 1))] += cx[i][j][k];68 行未改动int len = cx[2].size();if(cx[2].size() != cx[3].size()) return 1;if(cx[0].size() && cx[1].size() && !cx[2].size()) return 1;string res;for(int v : cx[0]) ans.push_back(v), res += 'J';if(len) ans.push_back(cx[2][0]), res += 'J';int now = 1;for(int v : cx[1]) ans.push_back(v), now ^= 1, res += (now ? 'J' : 'N');if(len) ans.push_back(cx[3][0]), now ^= 1, res += (now ? 'J' : 'N');20 行未改动```cppll n = rd(), c = rd(), ans = 0;for(ll i = 1; i <= c; i++) a[i] = rd();for(ll i = 1; i <= n; i++) p[i] = rd();for(ll i = 1; i <= n; i++)for(ll Q = rd(), x; Q--; ) x = rd(), cx[x].push_back(i);for(ll i = 1; i <= c; i++) {while(now[i] < cx[i].size() && a[i]) {ll x = cx[i][now[i]];2 行未改动}}cout << ans << '\n';for(ll i = 1; i < n; i++) {ll t = p[i], id = f[t];if(f[t]) ans -= t;vis[t] = 1;while(now[id] < cx[id].size()) {ll x = cx[id][now[id]];58 行未改动p[(i - 1) % n + 1] = f[q[l]] - 2 * q[l] + i;while(l <= r && f[q[r]] - 2 * q[r] > f[i] - 2 * i) r--;q[++r] = i;}for(int i = 1; i <= n; i++)cout << min(min(f[i] - i, n + i - g[i]), min(h[i], p[i])) << " \n"[i == n];```