QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#111224 | #6570. Who Watches the Watchmen? | applese | AC ✓ | 580ms | 5900kb | C++14 | 8.3kb | 2023-06-06 12:14:32 | 2023-06-06 12:14:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int maxn = 505;
namespace KM {
int n, matched[505], visy[505], lx[505], ly[505], pre[505];
long long e[505][505], slack[505];
void Bfs(int want_match) {
int now, new_match = 0, x = 0;
memset(pre, 0, sizeof pre);
memset(slack, 0x3f, sizeof slack);
matched[x] = want_match;
do {
now = matched[x];
long long delta = 1e18;
visy[x] = true;
for(int i = 1; i <= n; ++ i) {
if(!visy[i]) {
if(slack[i] > lx[now] + ly[i] - e[now][i]) {
slack[i] = lx[now] + ly[i] - e[now][i];
pre[i] = x;
}
if(slack[i] < delta) {
delta = slack[i];
new_match = i;
}
}
}
// cerr << " " << n << " " << new_match << " " << x << " " << matched[x] << " " << now << endl;
for(int i = 0; i <= n; ++ i) {
if(visy[i]) {
lx[matched[i]] -= delta;
ly[i] += delta;
}
else {
slack[i] -= delta;
}
}
x = new_match;
} while(matched[x]);
while(x) {
matched[x] = matched[pre[x]];
x = pre[x];
}
}
long long KM() {
memset(matched, 0, sizeof matched);
memset(lx, 0, sizeof lx);
memset(ly, 0, sizeof ly);
for(int i = 1; i <= n; ++ i) {
memset(visy, 0, sizeof visy);
Bfs(i);
}
// for(int i = 1; i <= n; ++ i)
// cerr << matched[i] << " " << i << endl;
long long ans = 0;
for(int i = 1; i <= n; ++ i)
ans += e[matched[i]][i];
return ans;
}
}
int Dcmp(double x) {
return x < -eps ? -1 : x > eps ? 1 : 0;
}
int n, id[maxn];
struct Point {
double x, y, z;
Point(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {}
bool operator == (const Point &rhs) const {
return Dcmp(x - rhs.x) == 0 && Dcmp(y - rhs.y) == 0 && Dcmp(z - rhs.z) == 0;
}
bool operator < (const Point &rhs) const {
return Dcmp(x - rhs.x) == 0 ? (Dcmp(y - rhs.y) == 0 ? Dcmp(z - rhs.z) < 0 : Dcmp(y - rhs.y) < 0) : Dcmp(x - rhs.x) < 0;
}
Point operator + (const Point &rhs) const {
return Point(x + rhs.x, y + rhs.y, z + rhs.z);
}
Point operator - (const Point &rhs) const {
return Point(x - rhs.x, y - rhs.y, z - rhs.z);
}
Point operator * (const double &k) const {
return Point(x * k, y * k, z * k);
}
Point operator / (const double &k) const {
return Point(x / k, y / k, z / k);
}
double operator * (const Point &rhs) const {
return x * rhs.x + y * rhs.y + z * rhs.z;
}
Point operator ^ (const Point &rhs) const {
return Point(y * rhs.z - z * rhs.y, z * rhs.x - x * rhs.z, x * rhs.y - y * rhs.x);
}
double len2() {
return x * x + y * y + z * z;
}
double len() {
return sqrt(len2());
}
Point Unit() {
return (*this) / len();
}
}p[maxn], v[maxn], np[maxn], nv[maxn];
struct Line {
Point s, t;
Line(Point s = Point(), Point t = Point()) : s(s), t(t) {}
double len2() {
return (t - s).len2();
}
double len() {
return (t - s).len();
}
};
double Area(Point a, Point b, Point c) {
return ((b - a) ^ (c - a)).len();
}
int PointOnSeg(Point p, Line l) {
return Dcmp(((l.s - p) ^ (l.t - p)).len2()) == 0 && Dcmp((l.s - p) * (l.t - p)) <= 0;
}
Point LinePro(Point p, Line l) {
return l.s + (((l.t - l.s) * ((l.t - l.s) * (p - l.s))) / (l.len2()));
}
int Inter(Line x, Line y) {
Point v1 = x.t - x.s, v2 = y.t - y.s;
// cerr << x.s.x << " " << x.s.y << " " << x.s.z << endl;
// cerr << x.t.x << " " << x.t.y << " " << x.t.z << endl;
// cerr << y.s.x << " " << y.s.y << " " << y.s.z << endl;
// cerr << y.t.x << " " << y.t.y << " " << y.t.z << endl;
// cerr << ((v1 ^ v2) * v2) << endl;
// cerr << (((x.s - y.s) ^ v2) * v2) << endl;
if(Dcmp((v1 ^ v2).len()) == 0)
return Dcmp(((x.s - y.s) ^ v2).len()) == 0 && (Dcmp(v1 * v2) > 0 || Dcmp((x.s - y.s) * v2) >= 0 || Dcmp((x.t - y.s) * v2) >= 0 || Dcmp((y.s - x.s) * v1) >= 0 || Dcmp((y.t - x.s) * v1) >= 0);
return Dcmp(((x.s - y.s) ^ v2) * (v1 ^ v2)) < 0 && Dcmp(((y.s - x.s) ^ v1) * (v2 ^ v1)) < 0;
}
struct Plane {
Point a, b, c, o;
Plane(){}
Plane(Point a, Point b, Point c) : a(a), b(b), c(c) {
o = Pvec();
}
Point Pvec() {
return (b - a) ^ (c - a);
}
};
int PointOnPlane(Point p, Plane pl) {
// cerr << pl.o.x << " " << pl.o.y << " " << pl.o.z << endl;
// cerr << ((p - pl.a) * pl.o) << endl;
return Dcmp((p - pl.a) * pl.o) == 0;
}
int spre[maxn], ssuf[maxn], spre2[maxn], ssuf2[maxn];
int main() {
scanf("%d", &n);
for(int i = 1, x, y, z; i <= n; ++ i) {
scanf("%d%d%d", &x, &y, &z);
p[i] = Point(x, y, z);
scanf("%d%d%d", &x, &y, &z);
v[i] = Point(x, y, z);
}
int l = 1;
for(int i = 3; i <= n; ++ i) {
if(Dcmp(Area(p[1], p[2], p[i]))) {
l = 0;
break;
}
}
if(n % 2 == 0 || !l) {
KM :: n = n;
int hav = 0;
for(int i = 1; i <= n; ++ i) {
for(int j = 1; j <= n; ++ j) {
KM :: e[i][j] = -1e9;
if(i == j)
continue;
int ons = 0;
for(int k = 1; k <= n; ++ k) {
if(i != k && j != k) {
if(PointOnSeg(p[k], Line(p[i], p[j]))) {
ons = 1;
break;
}
}
}
if(!ons) {
if((p[j] - p[i]).Unit() == v[i].Unit()) {
++ hav;
KM :: e[i][j] = 1;
}
else {
KM :: e[i][j] = 0;
}
}
// cerr << i << " " << j << " " << KM :: e[i][j] << endl;
}
}
long long ans = KM :: KM();
ans = 0;
for(int i = 1; i <= n; ++ i) {
int k = KM :: matched[i], none = 1;
for(int j = 1; j <= n; ++ j) {
if(KM :: e[k][j] == 1)
none = 0;
if(KM :: e[k][j] == 1 && j != i)
++ ans;
}
if(none)
++ ans;
}
assert(ans >= 0);
printf("%lld\n", ans);
}
else {
int res = 1e9;
for(int i = 1; i <= n; ++ i) {
int m = 0;
for(int j = 1; j <= n; ++ j) {
if(i != j) {
++ m;
np[m] = p[j];
nv[m] = v[j];
id[m] = m;
}
}
sort(id + 1, id + m + 1, [&](int a, int b) {
return np[a] < np[b];
});
for(int j = 0; j <= m + 2; ++ j) {
spre[j] = 0;
ssuf[j] = 0;
spre2[j] = 0;
ssuf2[j] = 0;
}
for(int j = 1; j < m; ++ j) {
int x = 1;
if((np[id[j + 1]] - np[id[j]]).Unit() == nv[id[j]].Unit()) {
x = 0;
}
spre[j] = spre[j - 1] + x;
spre2[j] = (j > 1 ? spre2[j - 2] : 0) + x;
}
for(int j = m; j > 1; -- j) {
int x = 1;
if((np[id[j - 1]] - np[id[j]]).Unit() == nv[id[j]].Unit()) {
x = 0;
}
ssuf[j] = ssuf[j + 1] + x;
ssuf2[j] = ssuf2[j + 2] + x;
}
for(int l = 1; l <= m; l += 2) {
for(int r = l + 1; r <= m; r += 2) {
int ans = 1000;
if(l > 1)
ans += spre2[l - 2] + ssuf2[2] - ssuf2[l + 1];
if(r < m)
ans += ssuf2[r + 2] + spre2[m - 1] - spre2[r - 1];
int ansl = spre[r - 1] - spre[l - 1], ansr = ssuf[l + 1] - ssuf[r + 1];
// cerr << spre[1] << " " << ansl << " " << ssuf[2] << " " << ansr << endl;
if(Dcmp(((np[id[m]] - np[id[1]]) ^ (v[i])).len()) == 0 && Dcmp(((np[id[m]] - np[id[1]]) ^ (nv[id[r]])).len()) == 0)
ansl += 2;
else {
// cerr << "!" << endl;
ansl += 1;
if(Dcmp(((np[id[m]] - np[id[1]]) ^ (v[i])).len()) != 0 && Dcmp(((np[id[m]] - np[id[1]]) ^ (nv[id[r]])).len()) != 0) {
Plane p = Plane(np[id[l]], np[id[r]], np[id[r]] + nv[id[r]]);
if(PointOnPlane(np[id[r]] + v[i], p)) {
// cerr << "!!" << endl;
Line l1 = Line(np[id[r]], np[id[r]] + nv[id[r]]), l2 = Line(np[id[l]], np[id[l]] - v[i]);
// cerr << Inter(l1, l2) << endl;
if(Inter(l1, l2))
-- ansl;
}
}
}
if(Dcmp(((np[id[m]] - np[id[1]]) ^ (v[i])).len()) == 0 && Dcmp(((np[id[m]] - np[id[1]]) ^ (nv[id[l]])).len()) == 0)
ansr += 2;
else {
ansr += 1;
if(Dcmp(((np[id[m]] - np[id[1]]) ^ (v[i])).len()) != 0 && Dcmp(((np[id[m]] - np[id[1]]) ^ (nv[id[l]])).len()) != 0) {
// cerr << "? " << endl;
Plane p = Plane(np[id[l]], np[id[r]], np[id[l]] + nv[id[l]]);
// Point tmp = np[id[l]] + v[i];
// cerr << tmp.x << " " << tmp.y << " " << tmp.z << endl;
if(PointOnPlane(np[id[l]] + v[i], p)) {
// cerr << "?? " << endl;
Line l1 = Line(np[id[l]], np[id[l]] + nv[id[l]]), l2 = Line(np[id[r]], np[id[r]] - v[i]);
if(Inter(l1, l2))
-- ansr;
}
}
}
// cerr << i << " " << l << " " << r << " " << ansl << " " << ansr << endl;
ans += min(ansl, ansr);
res = min(res, ans);
}
}
}
printf("%d\n", res > 2000 ? -1 : res);
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
7 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 -1 0 0
output:
1002
result:
ok single line: '1002'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
4 66 45 10 73 39 36 95 14 26 47 84 59 14 66 89 89 36 78 16 27 94 79 24 24
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
3 0 0 0 1 0 0 1 1 1 1 0 0 2 2 2 1 0 0
output:
1002
result:
ok single line: '1002'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
3 0 0 0 1 1 1 1 1 1 1 0 0 2 2 2 1 0 0
output:
1001
result:
ok single line: '1001'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3892kb
input:
3 0 0 0 1 0 0 1 1 1 1 0 0 2 2 2 -1 -1 -1
output:
1001
result:
ok single line: '1001'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
3 0 0 0 1 0 0 1 1 1 1 2 2 2 2 2 -1 -1 -1
output:
1000
result:
ok single line: '1000'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3664kb
input:
3 0 0 0 1 0 0 1 1 1 1 2 2 2 2 2 1 1 1
output:
1001
result:
ok single line: '1001'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3888kb
input:
1 0 0 0 3 1 4
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
4 0 0 0 1 1 1 1 0 0 -1 0 0 1 1 1 0 -1 0 1 0 1 0 1 0
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 210ms
memory: 5660kb
input:
500 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0 11 0 0 -1 0 0 12 0 0 1 0 0 13 0 0 -1 0 0 14 0 0 1 0 0 15 0 0 1 0 0 16 0 0 1 0 0 17 0 0 -1 0 0 18 0 0 -1 0 0 19 0 0 -1 0 0 20 0 0 -1 0 0 21 0 0 1 0 0 22 0 0 1 0 0...
output:
250
result:
ok single line: '250'
Test #11:
score: 0
Accepted
time: 210ms
memory: 5900kb
input:
500 0 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0 11 0 0 -1 0 0 12 0 0 1 0 0 13 0 0 -1 0 0 14 0 0 1 0 0 15 0 0 1 0 0 16 0 0 1 0 0 17 0 0 -1 0 0 18 0 0 -1 0 0 19 0 0 -1 0 0 20 0 0 -1 0 0 21 0 0 1 0 0 22 0 0 1 0...
output:
250
result:
ok single line: '250'
Test #12:
score: 0
Accepted
time: 210ms
memory: 5744kb
input:
500 0 0 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0 11 0 0 -1 0 0 12 0 0 1 0 0 13 0 0 -1 0 0 14 0 0 1 0 0 15 0 0 1 0 0 16 0 0 1 0 0 17 0 0 -1 0 0 18 0 0 -1 0 0 19 0 0 -1 0 0 20 0 0 -1 0 0 21 0 0 1 0 0 22 0 0 1...
output:
250
result:
ok single line: '250'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3844kb
input:
5 1 0 0 1 -1 0 2 0 0 0 1 0 3 0 0 -1 0 0 4 0 0 -1 0 0 5 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
5 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 0 1 0 5 0 0 -1 -1 0
output:
1000
result:
ok single line: '1000'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3920kb
input:
6 0 1 0 1 0 0 0 2 0 0 2 0 0 3 0 0 3 0 0 4 0 0 4 0 0 5 0 0 5 0 0 6 0 0 6 0
output:
4
result:
ok single line: '4'
Test #16:
score: 0
Accepted
time: 2ms
memory: 3936kb
input:
9 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1
output:
3
result:
ok single line: '3'
Test #17:
score: 0
Accepted
time: 116ms
memory: 3728kb
input:
499 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0 11 0 0 -1 0 0 12 0 0 1 0 0 13 0 0 -1 0 0 14 0 0 1 0 0 15 0 0 1 0 0 16 0 0 1 0 0 17 0 0 -1 0 0 18 0 0 -1 0 0 19 0 0 -1 0 0 20 0 0 -1 0 0 21 0 0 1 0 0 22 0 0 1 0 0...
output:
1220
result:
ok single line: '1220'
Test #18:
score: 0
Accepted
time: 105ms
memory: 3892kb
input:
499 0 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0 11 0 0 -1 0 0 12 0 0 1 0 0 13 0 0 -1 0 0 14 0 0 1 0 0 15 0 0 1 0 0 16 0 0 1 0 0 17 0 0 -1 0 0 18 0 0 -1 0 0 19 0 0 -1 0 0 20 0 0 -1 0 0 21 0 0 1 0 0 22 0 0 1 0...
output:
1220
result:
ok single line: '1220'
Test #19:
score: 0
Accepted
time: 107ms
memory: 3744kb
input:
499 0 0 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0 11 0 0 -1 0 0 12 0 0 1 0 0 13 0 0 -1 0 0 14 0 0 1 0 0 15 0 0 1 0 0 16 0 0 1 0 0 17 0 0 -1 0 0 18 0 0 -1 0 0 19 0 0 -1 0 0 20 0 0 -1 0 0 21 0 0 1 0 0 22 0 0 1...
output:
1220
result:
ok single line: '1220'
Test #20:
score: 0
Accepted
time: 2ms
memory: 3748kb
input:
5 0 0 0 0 -1 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 1 0 0
output:
1001
result:
ok single line: '1001'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3676kb
input:
5 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 0 1 0
output:
1001
result:
ok single line: '1001'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
5 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 0 -1 0 3 0 0 1 0 0 4 0 0 -1 0 0
output:
1001
result:
ok single line: '1001'
Test #23:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
5 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 0 -1 0 4 0 0 1 0 0
output:
1001
result:
ok single line: '1001'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
5 0 0 0 1 1 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 -1 -1 0
output:
1001
result:
ok single line: '1001'
Test #25:
score: 0
Accepted
time: 2ms
memory: 3672kb
input:
5 0 0 0 1 1 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 1 1 0
output:
1001
result:
ok single line: '1001'
Test #26:
score: 0
Accepted
time: 2ms
memory: 3884kb
input:
5 0 0 0 5 -1 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 1 -1 0
output:
1001
result:
ok single line: '1001'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3924kb
input:
17 0 0 0 0 0 1 0 1 0 0 0 1 0 2 0 0 0 1 0 3 0 0 0 1 0 4 0 0 0 1 0 -1 0 0 0 1 0 -2 0 0 0 1 0 -3 0 0 0 1 0 -4 0 0 0 1 1 3 0 0 0 1 2 3 0 0 0 1 -1 3 0 0 0 1 -2 3 0 0 0 1 1 -3 0 0 0 1 2 -3 0 0 0 1 -1 -3 0 0 0 1 -2 -3 0 0 0 1
output:
17
result:
ok single line: '17'
Test #28:
score: 0
Accepted
time: 2ms
memory: 3760kb
input:
17 0 0 0 0 4 0 0 1 0 0 -1 0 0 2 0 0 -2 0 0 3 0 0 -3 0 0 4 0 0 -4 0 0 -1 0 0 1 0 0 -2 0 0 2 0 0 -3 0 0 3 0 0 -4 0 0 4 0 1 3 0 -1 -3 0 2 3 0 -1 -2 0 -1 3 0 1 -3 0 -2 3 0 2 -3 0 1 -3 0 -1 3 0 2 -3 0 -2 3 0 -1 -3 0 1 3 0 -2 -3 0 2 3 0
output:
10
result:
ok single line: '10'
Test #29:
score: 0
Accepted
time: 2ms
memory: 3788kb
input:
17 0 0 0 0 1 0 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 2 -1 0 0 -1 0 0 1 0 0 -2 0 0 1 0 0 -3 0 0 1 0 0 -4 0 0 1 0 1 3 0 -1 0 0 2 3 0 -1 0 0 -1 3 0 -1 0 0 -2 3 0 4 -6 0 1 -3 0 -1 0 0 2 -3 0 -1 0 0 -1 -3 0 -1 0 0 -2 -3 0 2 -1 0
output:
3
result:
ok single line: '3'
Test #30:
score: 0
Accepted
time: 1ms
memory: 3884kb
input:
5 0 0 0 1 1 1 0 0 1 0 0 1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 -1 1
output:
1001
result:
ok single line: '1001'
Test #31:
score: 0
Accepted
time: 580ms
memory: 5900kb
input:
500 -455212 958307 274912 -88656 390687 881409 -498879 -623821 322766 -916023 347922 541726 -594515 -554311 -413504 -881701 -506880 -144667 658945 -503396 791805 314816 -830920 -769486 -200847 845218 468338 -166468 -49854 -287877 -820402 914874 916800 258029 -210000 -296727 702016 -389491 -31529 -52...
output:
499
result:
ok single line: '499'
Test #32:
score: 0
Accepted
time: 2ms
memory: 3672kb
input:
3 1000000 -1 -1 -1000000 -999999 -999999 -1 1000000 -1 101 -101 0 100 999899 -1 999999 1000000 999999
output:
1000
result:
ok single line: '1000'
Test #33:
score: 0
Accepted
time: 2ms
memory: 3672kb
input:
3 1000000 -1 -1 1000000 999999 999999 -1 1000000 -1 101 -101 0 100 999899 -1 999999 1000000 999999
output:
1001
result:
ok single line: '1001'
Test #34:
score: 0
Accepted
time: 2ms
memory: 3840kb
input:
3 1000000 -1 -1 -1000000 -999999 -999999 -1 1000000 -1 101 -101 0 100 999899 -1 -999999 -1000000 -999999
output:
1001
result:
ok single line: '1001'
Test #35:
score: 0
Accepted
time: 2ms
memory: 3844kb
input:
3 1000000 -1 -1 1000000 999999 999999 -1 1000000 -1 101 -101 0 100 999899 -1 -999999 -1000000 -999999
output:
1001
result:
ok single line: '1001'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
3 10 -1 -1 -10 -9 -9 -1 10 -1 11 -11 0 21 -12 -1 9 10 9
output:
1000
result:
ok single line: '1000'
Test #37:
score: 0
Accepted
time: 2ms
memory: 3676kb
input:
7 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 0 -1 0 3 0 0 1 0 0 4 0 0 -1 1 0 5 0 0 1 0 0 6 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #38:
score: 0
Accepted
time: 2ms
memory: 3912kb
input:
7 0 0 0 1 0 0 1 0 0 0 -1 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 -1 1 0 5 0 0 1 0 0 6 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
7 0 0 0 0 -1 0 1 0 0 1 0 0 2 0 0 -1 0 0 3 0 0 1 0 0 4 0 0 -1 1 0 5 0 0 1 0 0 6 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #40:
score: 0
Accepted
time: 2ms
memory: 3672kb
input:
7 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 1 0 4 0 0 0 -1 0 5 0 0 1 0 0 6 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #41:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
7 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 1 0 4 0 0 1 0 0 5 0 0 0 -1 0 6 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #42:
score: 0
Accepted
time: 2ms
memory: 3908kb
input:
7 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 1 0 4 0 0 1 0 0 5 0 0 -1 0 0 6 0 0 0 -1 0
output:
1000
result:
ok single line: '1000'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 0 1 0 5 0 0 1 -1 0 6 0 0 -1 0 0 7 0 0 -1 0 0 8 0 0 -1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #44:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 1 -1 0 5 0 0 0 1 0 6 0 0 -1 0 0 7 0 0 -1 0 0 8 0 0 -1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #45:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 0 1 0 5 0 0 -1 0 0 6 0 0 1 -1 0 7 0 0 -1 0 0 8 0 0 -1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #46:
score: 0
Accepted
time: 2ms
memory: 3748kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 0 1 0 5 0 0 -1 0 0 6 0 0 -1 0 0 7 0 0 1 -1 0 8 0 0 -1 0 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #47:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 -1 -1 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 0 1 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #48:
score: 0
Accepted
time: 2ms
memory: 3892kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 1 0 0 5 0 0 -1 -1 0 6 0 0 1 0 0 7 0 0 1 0 0 8 0 0 0 1 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #49:
score: 0
Accepted
time: 2ms
memory: 3732kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 -1 -1 0 7 0 0 1 0 0 8 0 0 0 1 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #50:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 -1 -1 0 8 0 0 0 1 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #51:
score: 0
Accepted
time: 2ms
memory: 3728kb
input:
11 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 -1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 1 0 0 7 0 0 0 1 0 8 0 0 -1 -1 0 9 0 0 1 0 0 10 0 0 -1 0 0
output:
1000
result:
ok single line: '1000'
Test #52:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
27 -1000000 -1000000 -1000000 1000000 0 1000000 -1000000 -1000000 0 -1000000 0 1000000 -1000000 -1000000 1000000 -1000000 0 1000000 -1000000 0 -1000000 1000000 1000000 1000000 -1000000 0 0 0 -1000000 1000000 -1000000 0 1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 0 1000000 -100...
output:
17
result:
ok single line: '17'
Test #53:
score: 0
Accepted
time: 209ms
memory: 5600kb
input:
500 -999983 -999981 -999977 17 19 23 -999966 -999962 -999954 17 19 23 -999949 -999943 -999931 17 19 23 -999932 -999924 -999908 17 19 23 -999915 -999905 -999885 17 19 23 -999898 -999886 -999862 17 19 23 -999881 -999867 -999839 17 19 23 -999864 -999848 -999816 17 19 23 -999847 -999829 -999793 17 19 23...
output:
250
result:
ok single line: '250'
Test #54:
score: 0
Accepted
time: 202ms
memory: 5712kb
input:
500 999983 999981 999977 -17 -19 -23 999966 999962 999954 -17 -19 -23 999949 999943 999931 -17 -19 -23 999932 999924 999908 -17 -19 -23 999915 999905 999885 -17 -19 -23 999898 999886 999862 -17 -19 -23 999881 999867 999839 -17 -19 -23 999864 999848 999816 -17 -19 -23 999847 999829 999793 -17 -19 -23...
output:
250
result:
ok single line: '250'
Test #55:
score: 0
Accepted
time: 265ms
memory: 5736kb
input:
500 999686 -999841 999735 -314 159 -265 999372 -999682 999470 -314 159 -265 999058 -999523 999205 314 -159 265 998744 -999364 998940 -314 159 -265 998430 -999205 998675 -314 159 -265 998116 -999046 998410 -314 159 -265 997802 -998887 998145 -314 159 -265 997488 -998728 997880 -314 159 -265 997174 -9...
output:
250
result:
ok single line: '250'
Test #56:
score: 0
Accepted
time: 235ms
memory: 5836kb
input:
500 999900 -999800 999700 -100 200 -300 999800 -999600 999400 -100 200 -300 999700 -999400 999100 100 -200 300 999600 -999200 998800 -100 200 -300 999500 -999000 998500 -100 200 -300 999400 -998800 998200 -100 200 -300 999300 -998600 997900 -100 200 -300 999200 -998400 997600 -100 200 -300 999100 -9...
output:
250
result:
ok single line: '250'
Test #57:
score: 0
Accepted
time: 21ms
memory: 5616kb
input:
480 -2402 3028 3274 23 -29 -31 -79 99 143 23 -29 -31 3854 -4860 -5158 -23 29 31 1370 -1728 -1810 -23 29 31 -4127 5203 5599 23 -29 -31 -5461 6885 7397 23 -29 -31 2382 -3004 -3174 -23 29 31 -1965 2477 2685 23 -29 -31 2888 -3642 -3856 -23 29 31 -3782 4768 5134 23 -29 -31 1899 -2395 -2523 -23 29 31 59 -...
output:
122
result:
ok single line: '122'
Test #58:
score: 0
Accepted
time: 22ms
memory: 5576kb
input:
480 43422 13353 -25668 414 129 -256 1608 324 188 414 129 -256 -69186 -21735 43964 -414 -129 256 -24474 -7803 16316 -414 -129 256 74472 23028 -44868 414 129 -256 98484 30510 -59716 414 129 -256 -42690 -13479 27580 -414 -129 256 35556 10902 -20804 414 129 -256 -51798 -16317 33212 -414 -129 256 68262 2...
output:
123
result:
ok single line: '123'
Test #59:
score: 0
Accepted
time: 5ms
memory: 4396kb
input:
180 375 636 1057 -4 -8 -12 47 -20 73 4 8 12 331 548 925 -4 -8 -12 -29 -172 -155 4 8 12 -153 -420 -527 4 8 12 427 740 1213 -4 -8 -12 -173 -460 -587 4 8 12 -241 -596 -791 4 8 12 179 244 469 -4 -8 -12 159 204 409 -4 -8 -12 -161 -436 -551 4 8 12 399 684 1129 -4 -8 -12 223 332 601 -4 -8 -12 59 4 109 -4 -...
output:
42
result:
ok single line: '42'
Test #60:
score: 0
Accepted
time: 3ms
memory: 4624kb
input:
220 27 -85 15 12 8 4 927 515 315 -12 -8 -4 -93 -165 -25 12 8 4 1083 619 367 -12 -8 -4 39 -77 19 12 8 4 -1281 -957 -421 12 8 4 1143 659 387 -12 -8 -4 183 19 67 -12 -8 -4 1047 595 355 -12 -8 -4 567 275 195 -12 -8 -4 531 251 183 -12 -8 -4 -177 -221 -53 12 8 4 579 283 199 -12 -8 -4 -561 -477 -181 12 8 4...
output:
52
result:
ok single line: '52'
Test #61:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
60 -171 215 267 23 -29 -31 473 -597 -601 -23 29 31 312 -394 -384 -23 29 31 404 -510 -508 -23 29 31 197 -249 -229 -23 29 31 335 -423 -415 -23 29 31 -654 824 918 23 -29 -31 -493 621 701 23 -29 -31 565 -713 -725 -23 29 31 -217 273 329 23 -29 -31 -631 795 887 23 -29 -31 496 -626 -632 -23 29 31 -447 563 ...
output:
17
result:
ok single line: '17'
Test #62:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
3 -1 0 0 2 1 0 1 0 0 -2 1 0 3 0 0 -2 -1 0
output:
1001
result:
ok single line: '1001'
Test #63:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
5 0 0 0 0 1 0 10 0 0 -1 1 0 0 10 0 -1 -1 0 -10 0 0 1 -1 0 0 -10 0 1 1 0
output:
1
result:
ok single line: '1'
Test #64:
score: 0
Accepted
time: 2ms
memory: 3764kb
input:
5 0 2 0 0 1 0 10 0 0 -1 1 0 0 10 0 -1 -1 0 -10 0 0 1 -1 0 0 -10 0 1 1 0
output:
1
result:
ok single line: '1'
Test #65:
score: 0
Accepted
time: 562ms
memory: 5876kb
input:
500 464689 -654475 874948 278641 -792884 186354 -798268 -885245 366579 415873 -814492 568386 548594 757214 459960 -318745 -320885 285634 -970144 68165 91372 -935576 -557281 -82177 -71496 697792 859229 603072 -751718 -629380 -391402 -320266 -691800 99295 771407 -415586 131176 -704350 628899 959024 80...
output:
500
result:
ok single line: '500'
Test #66:
score: 0
Accepted
time: 570ms
memory: 5696kb
input:
500 660575 -715271 73415 436140 226362 12224 19467 916145 -662062 -510604 824283 454499 205202 -915814 -735123 -110822 -83586 808202 13120 -72969 106150 -211607 557293 169887 -5849 149098 -624091 831479 -195891 -854258 335561 -450902 467595 -612441 695943 -877490 -356999 -751820 -886079 499927 46503...
output:
500
result:
ok single line: '500'
Test #67:
score: 0
Accepted
time: 570ms
memory: 5880kb
input:
500 -425261 857089 -722463 345227 -983886 -779314 873569 -40018 -490178 580005 -863510 -254613 -435240 -520380 84908 -513784 564739 330588 -932188 -477605 -347322 492032 -294079 477227 -72311 862368 -29594 -887377 -627667 -608677 -775504 -953650 8567 -11911 -162415 -485409 822275 -380961 773749 9387...
output:
500
result:
ok single line: '500'
Test #68:
score: 0
Accepted
time: 565ms
memory: 5660kb
input:
500 -132886 502058 -877447 79042 35022 -322286 101780 -909854 172531 103616 -119015 -271777 289064 -256857 -663836 977205 -748931 -999133 -68650 848633 -3718 -874892 260143 -880264 399836 -18330 881394 -913991 761700 620864 642012 105194 -288186 637083 -765709 -480047 -818650 -112345 310067 -918378 ...
output:
500
result:
ok single line: '500'
Test #69:
score: 0
Accepted
time: 571ms
memory: 5884kb
input:
500 -455212 958307 274912 -88656 390687 881409 -498879 -623821 322766 -916023 347922 541726 -594515 -554311 -413504 -881701 -506880 -144667 658945 -503396 791805 314816 -830920 -769486 -200847 845218 468338 -166468 -49854 -287877 -820402 914874 916800 258029 -210000 -296727 702016 -389491 -31529 -52...
output:
500
result:
ok single line: '500'