正文
增加 4 行删除 4 行
60 行未改动616263646566676869707172737475767778795 行未改动60 行未改动if (a[i].c != a[i - 1].c){r = i + 1;while (a[i].c == a[r].c) r++;//找右边线段// cout << l << " " << r << endl;}//找左边线段if (a[i].r > max1){if (a[i].c != maxt) max2 = max1, maxt = a[i].c;max1 = a[i].r;}else if (a[i].r > max2 && a[i].c != maxt) max2 = a[i].r;//记录答案,左边和右边取最小ans[a[i].id] = min (max (a[i].l - (a[i].c == maxt ? max2 : max1), 0ll), max (a[r].l - a[i].r, 0ll));}for (int i = 1; i <= n; i++) cout << ans[i] << " ";5 行未改动60 行未改动616263646566676869707172737475767778795 行未改动60 行未改动if (a[i].c != a[i - 1].c){r = i + 1;while (a[i].c == a[r].c) r++;//找右边线段// cout << l << " " << r << endl;}//找左边线段if (a[i].r > max1){if (a[i].c != maxt) max2 = max1, maxt = a[i].c;max1 = a[i].r;}else if (a[i].r > max2 && a[i].c != maxt) max2 = a[i].r;//记录答案,左边和右边取最小ans[a[i].id] = min (max (a[i].l - (a[i].c == maxt ? max2 : max1), 0ll), max (a[r].l - a[i].r, 0ll));}for (int i = 1; i <= n; i++) cout << ans[i] << " ";5 行未改动