正文
增加 7 行删除 7 行
40 行未改动41424344454647484950515253544 行未改动596061626364656667686970717273747576777879802 行未改动40 行未改动```c++int main() noexcept{read (n);for (i32 i = 1; i <= n; i++)for (i32 j = 1; j <= n; j++) {read (s[i][j]);G[s[i][j]].push_back ({i, j}); /*对于每种不同的颜色离线*/}for (i32 i = 1; i <= n * n; i++) {if (G[i].size ()) {std::sort (G[i].begin (), G[i].end ()); /*按照 x, y 升序排序*/for (auto it : G[i]) {4 行未改动for (auto it : G[i]) Tr.Mem (it.second);std::sort (G[i].begin (), G[i].end (), [&] (auto a, auto b) noexcept {return a.first == b.first ? a.second > b.second : a.first > b.first;}); /*反着做一遍*/for (auto it : G[i]) {i64 x = it.first, y = it.second;z[x][y] = Tr.ask (n - y + 1) + 1;Tr.update (n - y + 1, z[x][y]); /*同理*/}for (auto it : G[i]) Tr.Mem (n - it.second + 1); /*不能全局清空,不然复杂度会退化到 $O(n^3)$*/}}for (i32 i = 1; i <= n; i++)for (i32 j = 1; j <= n; j++)tot[v[i][j] + z[i][j] - 1]++;/*求出每个点的冗余度*/for (i32 i = 1; i <= n * 2 - 1; i++)put (tot[i]); /*输出答案*/return 0;}2 行未改动40 行未改动41424344454647484950515253544 行未改动596061626364656667686970717273747576777879802 行未改动40 行未改动```c++int main() noexcept{read (n);for (i32 i = 1; i <= n; i++)for (i32 j = 1; j <= n; j++) {read (s[i][j]);G[s[i][j]].push_back ({i, j}); /*对于每种不同的颜色离线*/}for (i32 i = 1; i <= n * n; i++) {if (G[i].size ()) {std::sort (G[i].begin (), G[i].end ()); /*按照 x, y 升序排序*/for (auto it : G[i]) {4 行未改动for (auto it : G[i]) Tr.Mem (it.second);std::sort (G[i].begin (), G[i].end (), [&] (auto a, auto b) noexcept {return a.first == b.first ? a.second > b.second : a.first > b.first;}); /*反着做一遍*/for (auto it : G[i]) {i64 x = it.first, y = it.second;z[x][y] = Tr.ask (n - y + 1) + 1;Tr.update (n - y + 1, z[x][y]); /*同理*/}for (auto it : G[i]) Tr.Mem (n - it.second + 1); /*不能全局清空,不然复杂度会退化到 $O(n^3)$*/}}for (i32 i = 1; i <= n; i++)for (i32 j = 1; j <= n; j++)tot[v[i][j] + z[i][j] - 1]++;/*求出每个点的冗余度*/for (i32 i = 1; i <= n * 2 - 1; i++)put (tot[i]); /*输出答案*/return 0;}2 行未改动