QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#358847 | #6570. Who Watches the Watchmen? | Delay_for_five_minutes | AC ✓ | 511ms | 4920kb | C++20 | 7.6kb | 2024-03-20 02:38:32 | 2024-03-20 02:38:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int INF = 1e7;
const int N = 505 ;
int n ;
array<int,3> p[505] , t[505];
int e[N][N];
int w[N*2],s[N*2],pre[N*2],mat[N*2],cur,pn;
bool vis[N*2];
void bfs(int x){
memset(vis,0,sizeof(vis));
memset(s,63,sizeof(s));
memset(pre,0,sizeof(pre));
cur=pn=0,mat[0]=x;
while(1){
x=mat[cur];
int dis=INF;
vis[cur]=1;
for(int i=n+1;i<=2*n;++i){
if(vis[i])continue;
int tmp=w[i]+w[x]-e[x][i-n];
if(tmp<s[i])s[i]=tmp,pre[i]=cur;
if(s[i]<dis)dis=s[i],pn=i;
}
w[mat[0]]-=dis,w[0]+=dis;
for(int i=n+1;i<=2*n;++i){
if(vis[i])w[i]+=dis,w[mat[i]]-=dis;
else s[i]-=dis;
}
cur=pn;
if(!mat[cur])break;
}
while(cur){
mat[cur]=mat[pre[cur]];
cur=pre[cur];
}
}
int KM(){
for(int i=1;i<=n;++i)bfs(i);
int res=0;
for(int i=1;i<=n;++i)if(mat[i+n])res+=e[mat[i+n]][i];
return res;
}
int sgn(int x) {
if(x > 0) return 1;
else if(x == 0) return 0;
return -1;
}
bool check(int i,int j) { ///i指向j
array<int,3> delta = {p[j][0] - p[i][0] , p[j][1] - p[i][1] , p[j][2] - p[i][2]} ;
if(sgn(delta[0]) == sgn(t[i][0]) && sgn(delta[1]) == sgn(t[i][1]) && sgn(delta[2]) == sgn(t[i][2]) ) {
if(1LL * delta[0] * t[i][1] == 1LL * delta[1] * t[i][0] && 1LL * delta[1] * t[i][2] == 1LL * delta[2] * t[i][1] && 1LL * delta[0] * t[i][2] == 1LL * delta[2] * t[i][0]) {
// printf("%d %d %d : %d %d %d\n",delta[0],delta[1],delta[2] , t[i][0],t[i][1],t[i][2]) ;
// assert((delta[0] == t[i][0] && delta[1] == t[i][1] && delta[2] == t[i][2]) || (delta[0] == t[i][0]*2 && delta[1] == t[i][1]*2 && delta[2] == t[i][2]*2));
return 1;
}
return 0;
}
return 0;
}
bool gx(int i,int j) {
array<int,3> delta = {p[j][0] - p[i][0] , p[i][1] - p[j][1] , p[i][2] - p[j][2]} ;
if(1LL * delta[0] * t[i][1] == 1LL * delta[1] * t[i][0] && 1LL * delta[1] * t[i][2] == 1LL * delta[2] * t[i][1] && 1LL * delta[0] * t[i][2] == 1LL * delta[2] * t[i][0]) return 1;
return 0;
}
bool par(int i,int j) {
if(1LL * t[i][0] * t[j][1] == 1LL * t[i][1] * t[j][0] && 1LL * t[i][1] * t[j][2] == 1LL * t[i][2] * t[j][1] && 1LL * t[i][0] * t[j][2] == 1LL * t[i][2] * t[j][0]) return 1;
return 0;
}
typedef pair<ll,ll> pll ;
pair<pll,pll> solve(array<int,3> u1,array<int,3> u2) {
ll a = 1LL * u1[2] * (-u2[0]) + 1LL * u2[2] * u1[0] ; /// a/b
ll b = 1LL * u1[1] * (-u2[0]) + 1LL * u2[1] * u1[0] ;
ll g = __gcd(a , b) ;
if(g) {
a /= g;b /= g;
}
if(b < 0) a *= -1 , b *= -1;
ll c = 1LL * u1[2] * (-u2[1]) + 1LL * u2[2] * u1[1] ; /// c/d
ll d = 1LL * u1[0] * (-u2[1]) + 1LL * u2[0] * u1[1] ;
g = __gcd(c , d) ;
if(g) {
c /= g;d /= g;
}
if(d < 0) c *= -1 , d *= -1;
return {(pll){c,d},(pll){a,b}} ;
}
bool zero(pll &A) {
return (A.first == 0 && A.second == 0) ;
}
int get_ans(int i,int j,int k) {
if(gx(i , j) && gx(k , j)) return 2;
// printf("chk %d %d %d\n",i,j,k) ;
if(gx(i , j) || gx(k , j)) return 1;
if(par(i , k)) return 1;
pair<pll,pll> a1 = solve({t[i][0] , t[k][0] , p[j][0] - p[k][0]} , {t[i][1] , t[k][1] , p[j][1] - p[k][1]}) ;
// printf("s1 %lld %lld : %lld %lld\n",a1.first.first,a1.first.second,a1.second.first,a1.second.second) ;
if(a1.first.first < 0 || a1.second.first < 0) return 1;
pair<pll,pll> a2 = solve({t[i][0] , t[k][0] , p[j][0] - p[k][0]} , {t[i][2] , t[k][2] , p[j][2] - p[k][2]}) ;
// printf("s1 %lld %lld : %lld %lld\n",a1.first.first,a1.first.second,a1.second.first,a1.second.second) ;
// printf("s2 %lld %lld : %lld %lld\n",a2.first.first,a2.first.second,a2.second.first,a2.second.second) ;
if((a2.first != a1.first && !zero(a2.first) && !zero(a1.first)) || (a2.second != a1.second && !zero(a2.second) && !zero(a2.second))) return 1;
// printf("ret 0\n") ;
return 0;
}
int id[505];
void work() {
int ans = 1e7;
for(int i = 1;i <= n;i++) id[i] = i;
sort(id + 1 , id + n + 1 , [&](int x,int y) {
if(p[x][0] != p[y][0]) return p[x][0] < p[y][0] ;
if(p[x][1] != p[y][1]) return p[x][1] < p[y][1] ;
return p[x][2] < p[y][2];
});
if(n % 2 == 0) {
int ans = 0;
for(int i = 1;i <= n;i += 2) {
ans += (2 - check(id[i] , id[i + 1]) - check(id[i + 1] , id[i])) ;
}
cout << ans << '\n' ;
return ;
}
for(int i = 1;i <= n;i++) {
vector<int> v;
for(int j = 1;j <= n;j++) {
if(j != i ) v.push_back(j) ;
}
vector<int> pre(v.size()) , suf(v.size());
for(int i = 0;i + 1 < v.size();i += 2) {
if(i) pre[i + 1] = pre[i - 1] ;
pre[i + 1] += 2 - (check(id[v[i]] , id[v[i + 1]]) + check(id[v[i + 1]] , id[v[i]]) );
}
for(int i = v.size() - 1;i - 1 >= 0;i -= 2) {
if(i != v.size() - 1) suf[i - 1] = suf[i + 1];
suf[i - 1] += 2 - (check(id[v[i]] , id[v[i - 1]]) + check(id[v[i - 1]] , id[v[i]])) ;
}
int sol = 1e7;
for(int j = 0;j < v.size();j++) {
int cur1 = 0 , cur2 = 0;
if(j % 2 == 1) continue ;
for(int k = j + 1;k < v.size();k++) {
cur1 += 1 - check(id[v[k - 1]] , id[v[k]]) ;
cur2 += 1 - check(id[v[k]] , id[v[k - 1]]) ;
// printf("%d %d %d\n",j,k,v.size()) ;
if((v.size() - k) % 2 == 0) continue ;
// printf("here\n") ;
int ad = 0;
if(j > 0) ad += pre[j - 1] ;
if(k < v.size() - 1) ad += suf[k + 1];
// printf("%d %d %d : %d %d\n",i,j,k,cur1,ad) ;
sol = min(sol , cur1 + get_ans(id[i] , id[v[j]] , id[v[k]]) + ad) ;
sol = min(sol , cur2 + get_ans(id[i] , id[v[k]] , id[v[j]]) + ad) ;
// printf("%d %d %d : %d\n",i,j,k , sol) ;
}
}
ans = min(ans , sol) ;
}
cout << (ans + 1000) << '\n' ;
return ;
}
int main() {
cin >> n;
for(int i = 1;i <= n;i++) {
for(int j = 0;j < 3;j++) cin >> p[i][j];
for(int j = 0;j < 3;j++) cin >> t[i][j];
}
if(n == 1) {
cout << -1 << '\n' ; return 0;
}
if(n == 2) {
int ans = check(1 , 2) + check(2 , 1);
cout << (2-ans) << '\n' ; return 0;
}
for(int i = n;i >= 1;i--) {
for(int j = 0;j < 3;j++) p[i][j] -= p[1][j] ;
}
bool ff = 1;
for(int i = 3;i <= n;i++) {
if(!(1LL * p[i][0] * p[2][1] == 1LL * p[i][1] * p[2][0] && 1LL * p[i][1] * p[2][2] == 1LL * p[i][2] * p[2][1])) {ff = 0;break ;}
}
if(ff) {
work() ; return 0;
}
for(int i = 1;i <= n;i++) {
map<array<int,3> , vector<pii> > mp;
e[i][i] = 1e7;
for(int j = 1;j <= n;j++) {
if(i == j) continue ;
array<int,3> ar = {p[j][0] - p[i][0] , p[j][1] - p[i][1] , p[j][2] - p[i][2]} ;
int g = abs(ar[0]) ; g = __gcd(g , abs(ar[1])) ; g = __gcd(g , abs(ar[2])) ;
ar[0] /= g ; ar[1] /= g ; ar[2] /= g;
mp[ar].push_back({g , j}) ;
}
for(auto &[u,v] : mp) {
sort(v.begin() , v.end()) ;
// printf("%d : %d %d %d\n",i,u[0],u[1],u[2]) ;
e[i][v[0].second] = 1 - check(i , v[0].second) ;
for(int j = 1;j < v.size();j++) e[i][v[j].second] = 1e7;
}
for(int j = 1;j <= n;j++ ) { e[i][j] *= -1 ; }
// printf("\n") ;
}
cout << -KM() << '\n' ;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
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: 3652kb
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: 3628kb
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: 3828kb
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: 0ms
memory: 3492kb
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: 0ms
memory: 3632kb
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: 0ms
memory: 3632kb
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: 0ms
memory: 3624kb
input:
1 0 0 0 3 1 4
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3652kb
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: 1ms
memory: 3524kb
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: 1ms
memory: 3572kb
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: 1ms
memory: 3572kb
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: 0ms
memory: 3856kb
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: 0ms
memory: 3632kb
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: 0ms
memory: 3512kb
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: 0ms
memory: 3856kb
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: 478ms
memory: 3620kb
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: 464ms
memory: 3640kb
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: 511ms
memory: 3672kb
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: 0ms
memory: 3568kb
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: 0ms
memory: 3792kb
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: 3620kb
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: 0ms
memory: 3628kb
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: 3516kb
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: 0ms
memory: 3624kb
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: 0ms
memory: 3604kb
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: 0ms
memory: 3680kb
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: 0ms
memory: 3928kb
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: 0ms
memory: 3672kb
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: 0ms
memory: 3564kb
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: 144ms
memory: 4596kb
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: 0ms
memory: 3636kb
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: 0ms
memory: 3636kb
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: 0ms
memory: 3632kb
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: 0ms
memory: 3604kb
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: 3636kb
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: 0ms
memory: 3568kb
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: 0ms
memory: 3636kb
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: 3628kb
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: 1ms
memory: 3512kb
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: 0ms
memory: 3860kb
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: 0ms
memory: 3636kb
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: 3864kb
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: 0ms
memory: 3608kb
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: 0ms
memory: 3636kb
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: 0ms
memory: 3572kb
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: 0ms
memory: 3616kb
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: 0ms
memory: 3860kb
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: 0ms
memory: 3568kb
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: 0ms
memory: 3636kb
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: 0ms
memory: 3632kb
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: 1ms
memory: 3704kb
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: 1ms
memory: 3580kb
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: 1ms
memory: 3576kb
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: 1ms
memory: 3636kb
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: 1ms
memory: 3548kb
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: 17ms
memory: 4588kb
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: 10ms
memory: 4656kb
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: 0ms
memory: 3976kb
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: 4048kb
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: 3708kb
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: 0ms
memory: 3824kb
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: 3536kb
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: 0ms
memory: 3876kb
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: 142ms
memory: 4688kb
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: 139ms
memory: 4684kb
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: 139ms
memory: 4920kb
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: 142ms
memory: 4688kb
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: 143ms
memory: 4620kb
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'