Submission #20379

# Submission time Handle Problem Language Result Execution time Memory
20379 2017-02-07T10:13:41 Z Can polan into space? (OJUZ11_space) C++
100 / 100
181 ms 28212 KB
/*#include<stdio.h>
#include<algorithm>
using namespace std;
int w[101000];
struct point{
    int t, num, c;
}P[101000];
int n, m, Mn[101000], Mx[101000], S[101000], C1[101000], C2[101000], G[101000], chk[101000];
bool Pos(int K){
    int i, rem = 0;
    for(i=1;i<=n;i++)Mn[i] = 1e9, Mx[i] = 0;
    for(i=1;i<=m;i++)C1[i] = C2[i] = 0, G[i] = 0, chk[i] = 0, S[i] = 0;
    chk[m+1] = 1;G[m+1]=G[0]=0;
    for(i=1;i<=K;i++){
        Mx[P[i].num] = max(Mx[P[i].num], P[i].t);
        Mn[P[i].num] = min(Mn[P[i].num], P[i].t);
        if(G[P[i].t] && G[P[i].t] != P[i].c)return false;
        G[P[i].t] = P[i].c;
        chk[P[i].t] = 1;
    }
    for(i=1;i<=m;i++){
        if(!Mx[i]){
            rem++;
        }
        else{
            S[Mn[i]]++, S[Mx[i]+1]--;
            C1[Mn[i]-1]++;
            C2[Mx[i]+1]++;
        }
    }
    for(i=1;i<=m;i++){
        S[i] += S[i-1];
        if(chk[i] && S[i] > G[i])return false;
    }
    for(i=1;i<=m;i++){
        G[i] -= S[i];
    }
    int t = 0;
    for(i=m;i>=1;i--){
        t +=C1[i];
        if(chk[i]){
            t = min(t,G[i]);
            G[i] -= t;
        }
    }
    t = 0;
    for(i=1;i<=m;i++){
        t +=C2[i];
        if(chk[i]){
            t = min(t,G[i]);
            G[i] -= t;
        }
    }
    t = 0;
    rem *= 2;
    for(i=1;i<=m;i++){
        if(chk[i]){
            rem -= (t-G[i]<0?G[i]-t:t-G[i]);
            t = G[i];
            if(rem<0)return false;
        }
    }
    return true;
}
int main(){
    int i, TC;
    scanf("%d",&TC);
    while(TC--){
        scanf("%d%d",&n,&m);
        for(i=1;i<=m;i++){
            scanf("%d%d%d",&P[i].t,&P[i].num,&P[i].c);
            P[i].c++;
        }
        int b = 1, e = m, mid, res = 0;
        while(b<=e){
            mid = (b+e)>>1;
            if(Pos(mid)){
                res = mid;
                b = mid + 1;
            }
            else e = mid - 1;
        }
        printf("%d\n",res);
    }
}*/
/*#include<cstdio>
#include<algorithm>
using namespace std;
int n, L, cnt;
struct point{
    long long x, y;
    int ck;
}w[301000];
int st[301000];
long long ccw(point a, point b, point c){
    return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}
double Get(point a, point b){
    return b.x - 1.0*b.y/(b.y-a.y)*(b.x-a.x);
}
struct AA{
    double x;
    int c = 0;
    bool operator<(const AA &p)const{
        return x<p.x;
    }
}ord[1201000];
void Add(double b, double e, int ck){
    if(ck){
        swap(b,e);
        b=L-b,e=L-e;
    }
    ord[cnt].x = b, ord[cnt].c = 1, cnt++;
    ord[cnt].x = e, ord[cnt].c = -1, cnt++;
}
void Do(int ck){
    int top = 0, i;
    st[++top] = 0;
    for(i=1;i<=n;i++){
        double tx = w[i-1].x;
        while(top > 1){
            double x = Get(w[st[top-1]], w[st[top]]);
            if(x > w[i].x)break;
            if(w[st[top]].ck){
                Add(tx,w[i].x,ck);
                tx = w[i].x;
                top--;
                break;
            }
            tx = x;
            top--;
        }
        if(w[st[top]].ck)Add(tx,w[i].x,ck);
        while(top > 1 && ccw(w[st[top-1]], w[st[top]], w[i]) >= 0) top--;
        while(top && w[st[top]].y <= w[i].y)top--;
        st[++top] = i;
    }
}
int main(){
    int i, s = 0;
    double res = 0.0;
    scanf("%d%d",&n,&L);
    for(i=1;i<=n;i++){
        scanf("%d%lld%lld",&w[i].ck,&w[i].x,&w[i].y);
    }
    n++;
    w[n].x = L;
    Do(0);
    for(i=0;i<=n/2;i++)swap(w[i],w[n-i]);
    for(i=0;i<=n;i++)w[i].x=L-w[i].x;
    Do(1);
    sort(ord,ord+cnt);
    for(i=0;i<cnt-1;i++){
        s += ord[i].c;
        if(s)res += ord[i+1].x-ord[i].x;
    }
    printf("%.9f\n",res);
}*/
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int C[501000][3];
long long D[501000][2];
int n, Path[501000][2], Q[501000], Deg[501000];
vector<int>E[501000];
int main(){
    int i, head = 0, tail = 0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d%d",&C[i][0],&C[i][1],&C[i][2]);
    }
    D[0][0] = -1e18;
    for(i=1;i<=n;i++){
        long long t1 = D[i-1][0] + C[i][1], t2 = D[i-1][1] + C[i][0];
        if(t1 > t2)D[i][0] = t1, Path[i][0] = 0;
        else D[i][0] = t2, Path[i][0] = 1;
        t1 = D[i-1][0] + C[i][2], t2 = D[i-1][1] + C[i][1];
        if(t1 > t2)D[i][1] = t1, Path[i][1] = 0;
        else D[i][1] = t2, Path[i][1] = 1;
    }
    int x = n, y = 0;
    printf("%lld\n",D[x][y]);
    while(x!=1){
        int t = Path[x][y];
        if(t==0)E[x-1].push_back(x), Deg[x]++;
        else E[x].push_back(x-1), Deg[x-1]++;
        x--,y=t;
    }
    for(i=1;i<=n;i++){
        if(!Deg[i])Q[++tail] = i;
    }
    while(head < tail){
        x = Q[++head];
        printf("%d ",x);
        for(i=0;i<E[x].size();i++){
            Deg[E[x][i]]--;
            if(!Deg[E[x][i]])Q[++tail] = E[x][i];
        }
    }
}

Compilation message

space.cpp: In function 'int main()':
space.cpp:196:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<E[x].size();i++){
                  ^
space.cpp:169:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
space.cpp:171:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&C[i][0],&C[i][1],&C[i][2]);
                                                   ^
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12024 KB Output is correct
2 Correct 9 ms 12024 KB Output is correct
3 Correct 9 ms 12112 KB Output is correct
4 Correct 9 ms 12112 KB Output is correct
5 Correct 9 ms 12112 KB Output is correct
6 Correct 9 ms 12112 KB Output is correct
7 Correct 11 ms 12112 KB Output is correct
8 Correct 10 ms 12112 KB Output is correct
9 Correct 9 ms 12112 KB Output is correct
10 Correct 9 ms 12172 KB Output is correct
11 Correct 9 ms 12172 KB Output is correct
12 Correct 9 ms 12172 KB Output is correct
13 Correct 9 ms 12172 KB Output is correct
14 Correct 12 ms 12172 KB Output is correct
15 Correct 9 ms 12172 KB Output is correct
16 Correct 10 ms 12172 KB Output is correct
17 Correct 10 ms 12172 KB Output is correct
18 Correct 10 ms 12172 KB Output is correct
19 Correct 11 ms 12172 KB Output is correct
20 Correct 9 ms 12172 KB Output is correct
21 Correct 9 ms 12172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12024 KB Output is correct
2 Correct 9 ms 12024 KB Output is correct
3 Correct 9 ms 12112 KB Output is correct
4 Correct 9 ms 12112 KB Output is correct
5 Correct 9 ms 12112 KB Output is correct
6 Correct 9 ms 12112 KB Output is correct
7 Correct 11 ms 12112 KB Output is correct
8 Correct 10 ms 12112 KB Output is correct
9 Correct 9 ms 12112 KB Output is correct
10 Correct 9 ms 12172 KB Output is correct
11 Correct 9 ms 12172 KB Output is correct
12 Correct 9 ms 12172 KB Output is correct
13 Correct 9 ms 12172 KB Output is correct
14 Correct 12 ms 12172 KB Output is correct
15 Correct 9 ms 12172 KB Output is correct
16 Correct 10 ms 12172 KB Output is correct
17 Correct 10 ms 12172 KB Output is correct
18 Correct 10 ms 12172 KB Output is correct
19 Correct 11 ms 12172 KB Output is correct
20 Correct 9 ms 12172 KB Output is correct
21 Correct 9 ms 12172 KB Output is correct
22 Correct 9 ms 12172 KB Output is correct
23 Correct 9 ms 12196 KB Output is correct
24 Correct 9 ms 12196 KB Output is correct
25 Correct 9 ms 12196 KB Output is correct
26 Correct 9 ms 12196 KB Output is correct
27 Correct 9 ms 12196 KB Output is correct
28 Correct 9 ms 12196 KB Output is correct
29 Correct 9 ms 12196 KB Output is correct
30 Correct 11 ms 12196 KB Output is correct
31 Correct 9 ms 12196 KB Output is correct
32 Correct 9 ms 12196 KB Output is correct
33 Correct 11 ms 12196 KB Output is correct
34 Correct 9 ms 12196 KB Output is correct
35 Correct 9 ms 12196 KB Output is correct
36 Correct 9 ms 12196 KB Output is correct
37 Correct 9 ms 12196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12024 KB Output is correct
2 Correct 9 ms 12024 KB Output is correct
3 Correct 9 ms 12112 KB Output is correct
4 Correct 9 ms 12112 KB Output is correct
5 Correct 9 ms 12112 KB Output is correct
6 Correct 9 ms 12112 KB Output is correct
7 Correct 11 ms 12112 KB Output is correct
8 Correct 10 ms 12112 KB Output is correct
9 Correct 9 ms 12112 KB Output is correct
10 Correct 9 ms 12172 KB Output is correct
11 Correct 9 ms 12172 KB Output is correct
12 Correct 9 ms 12172 KB Output is correct
13 Correct 9 ms 12172 KB Output is correct
14 Correct 12 ms 12172 KB Output is correct
15 Correct 9 ms 12172 KB Output is correct
16 Correct 10 ms 12172 KB Output is correct
17 Correct 10 ms 12172 KB Output is correct
18 Correct 10 ms 12172 KB Output is correct
19 Correct 11 ms 12172 KB Output is correct
20 Correct 9 ms 12172 KB Output is correct
21 Correct 9 ms 12172 KB Output is correct
22 Correct 9 ms 12172 KB Output is correct
23 Correct 9 ms 12196 KB Output is correct
24 Correct 9 ms 12196 KB Output is correct
25 Correct 9 ms 12196 KB Output is correct
26 Correct 9 ms 12196 KB Output is correct
27 Correct 9 ms 12196 KB Output is correct
28 Correct 9 ms 12196 KB Output is correct
29 Correct 9 ms 12196 KB Output is correct
30 Correct 11 ms 12196 KB Output is correct
31 Correct 9 ms 12196 KB Output is correct
32 Correct 9 ms 12196 KB Output is correct
33 Correct 11 ms 12196 KB Output is correct
34 Correct 9 ms 12196 KB Output is correct
35 Correct 9 ms 12196 KB Output is correct
36 Correct 9 ms 12196 KB Output is correct
37 Correct 9 ms 12196 KB Output is correct
38 Correct 9 ms 12196 KB Output is correct
39 Correct 9 ms 12196 KB Output is correct
40 Correct 9 ms 12196 KB Output is correct
41 Correct 9 ms 12196 KB Output is correct
42 Correct 9 ms 12196 KB Output is correct
43 Correct 10 ms 12196 KB Output is correct
44 Correct 9 ms 12196 KB Output is correct
45 Correct 9 ms 12196 KB Output is correct
46 Correct 9 ms 12196 KB Output is correct
47 Correct 10 ms 12196 KB Output is correct
48 Correct 9 ms 12200 KB Output is correct
49 Correct 9 ms 12200 KB Output is correct
50 Correct 10 ms 12200 KB Output is correct
51 Correct 9 ms 12200 KB Output is correct
52 Correct 9 ms 12200 KB Output is correct
53 Correct 11 ms 12200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12024 KB Output is correct
2 Correct 9 ms 12024 KB Output is correct
3 Correct 9 ms 12112 KB Output is correct
4 Correct 9 ms 12112 KB Output is correct
5 Correct 9 ms 12112 KB Output is correct
6 Correct 9 ms 12112 KB Output is correct
7 Correct 11 ms 12112 KB Output is correct
8 Correct 10 ms 12112 KB Output is correct
9 Correct 9 ms 12112 KB Output is correct
10 Correct 9 ms 12172 KB Output is correct
11 Correct 9 ms 12172 KB Output is correct
12 Correct 9 ms 12172 KB Output is correct
13 Correct 9 ms 12172 KB Output is correct
14 Correct 12 ms 12172 KB Output is correct
15 Correct 9 ms 12172 KB Output is correct
16 Correct 10 ms 12172 KB Output is correct
17 Correct 10 ms 12172 KB Output is correct
18 Correct 10 ms 12172 KB Output is correct
19 Correct 11 ms 12172 KB Output is correct
20 Correct 9 ms 12172 KB Output is correct
21 Correct 9 ms 12172 KB Output is correct
22 Correct 9 ms 12172 KB Output is correct
23 Correct 9 ms 12196 KB Output is correct
24 Correct 9 ms 12196 KB Output is correct
25 Correct 9 ms 12196 KB Output is correct
26 Correct 9 ms 12196 KB Output is correct
27 Correct 9 ms 12196 KB Output is correct
28 Correct 9 ms 12196 KB Output is correct
29 Correct 9 ms 12196 KB Output is correct
30 Correct 11 ms 12196 KB Output is correct
31 Correct 9 ms 12196 KB Output is correct
32 Correct 9 ms 12196 KB Output is correct
33 Correct 11 ms 12196 KB Output is correct
34 Correct 9 ms 12196 KB Output is correct
35 Correct 9 ms 12196 KB Output is correct
36 Correct 9 ms 12196 KB Output is correct
37 Correct 9 ms 12196 KB Output is correct
38 Correct 9 ms 12196 KB Output is correct
39 Correct 9 ms 12196 KB Output is correct
40 Correct 9 ms 12196 KB Output is correct
41 Correct 9 ms 12196 KB Output is correct
42 Correct 9 ms 12196 KB Output is correct
43 Correct 10 ms 12196 KB Output is correct
44 Correct 9 ms 12196 KB Output is correct
45 Correct 9 ms 12196 KB Output is correct
46 Correct 9 ms 12196 KB Output is correct
47 Correct 10 ms 12196 KB Output is correct
48 Correct 9 ms 12200 KB Output is correct
49 Correct 9 ms 12200 KB Output is correct
50 Correct 10 ms 12200 KB Output is correct
51 Correct 9 ms 12200 KB Output is correct
52 Correct 9 ms 12200 KB Output is correct
53 Correct 11 ms 12200 KB Output is correct
54 Correct 10 ms 12200 KB Output is correct
55 Correct 17 ms 12856 KB Output is correct
56 Correct 18 ms 12964 KB Output is correct
57 Correct 16 ms 12964 KB Output is correct
58 Correct 20 ms 12964 KB Output is correct
59 Correct 17 ms 12964 KB Output is correct
60 Correct 16 ms 12964 KB Output is correct
61 Correct 15 ms 12984 KB Output is correct
62 Correct 15 ms 12984 KB Output is correct
63 Correct 12 ms 12984 KB Output is correct
64 Correct 18 ms 12984 KB Output is correct
65 Correct 16 ms 12984 KB Output is correct
66 Correct 18 ms 12984 KB Output is correct
67 Correct 13 ms 12984 KB Output is correct
68 Correct 13 ms 12984 KB Output is correct
69 Correct 19 ms 12984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12024 KB Output is correct
2 Correct 9 ms 12024 KB Output is correct
3 Correct 9 ms 12112 KB Output is correct
4 Correct 9 ms 12112 KB Output is correct
5 Correct 9 ms 12112 KB Output is correct
6 Correct 9 ms 12112 KB Output is correct
7 Correct 11 ms 12112 KB Output is correct
8 Correct 10 ms 12112 KB Output is correct
9 Correct 9 ms 12112 KB Output is correct
10 Correct 9 ms 12172 KB Output is correct
11 Correct 9 ms 12172 KB Output is correct
12 Correct 9 ms 12172 KB Output is correct
13 Correct 9 ms 12172 KB Output is correct
14 Correct 12 ms 12172 KB Output is correct
15 Correct 9 ms 12172 KB Output is correct
16 Correct 10 ms 12172 KB Output is correct
17 Correct 10 ms 12172 KB Output is correct
18 Correct 10 ms 12172 KB Output is correct
19 Correct 11 ms 12172 KB Output is correct
20 Correct 9 ms 12172 KB Output is correct
21 Correct 9 ms 12172 KB Output is correct
22 Correct 9 ms 12172 KB Output is correct
23 Correct 9 ms 12196 KB Output is correct
24 Correct 9 ms 12196 KB Output is correct
25 Correct 9 ms 12196 KB Output is correct
26 Correct 9 ms 12196 KB Output is correct
27 Correct 9 ms 12196 KB Output is correct
28 Correct 9 ms 12196 KB Output is correct
29 Correct 9 ms 12196 KB Output is correct
30 Correct 11 ms 12196 KB Output is correct
31 Correct 9 ms 12196 KB Output is correct
32 Correct 9 ms 12196 KB Output is correct
33 Correct 11 ms 12196 KB Output is correct
34 Correct 9 ms 12196 KB Output is correct
35 Correct 9 ms 12196 KB Output is correct
36 Correct 9 ms 12196 KB Output is correct
37 Correct 9 ms 12196 KB Output is correct
38 Correct 9 ms 12196 KB Output is correct
39 Correct 9 ms 12196 KB Output is correct
40 Correct 9 ms 12196 KB Output is correct
41 Correct 9 ms 12196 KB Output is correct
42 Correct 9 ms 12196 KB Output is correct
43 Correct 10 ms 12196 KB Output is correct
44 Correct 9 ms 12196 KB Output is correct
45 Correct 9 ms 12196 KB Output is correct
46 Correct 9 ms 12196 KB Output is correct
47 Correct 10 ms 12196 KB Output is correct
48 Correct 9 ms 12200 KB Output is correct
49 Correct 9 ms 12200 KB Output is correct
50 Correct 10 ms 12200 KB Output is correct
51 Correct 9 ms 12200 KB Output is correct
52 Correct 9 ms 12200 KB Output is correct
53 Correct 11 ms 12200 KB Output is correct
54 Correct 10 ms 12200 KB Output is correct
55 Correct 17 ms 12856 KB Output is correct
56 Correct 18 ms 12964 KB Output is correct
57 Correct 16 ms 12964 KB Output is correct
58 Correct 20 ms 12964 KB Output is correct
59 Correct 17 ms 12964 KB Output is correct
60 Correct 16 ms 12964 KB Output is correct
61 Correct 15 ms 12984 KB Output is correct
62 Correct 15 ms 12984 KB Output is correct
63 Correct 12 ms 12984 KB Output is correct
64 Correct 18 ms 12984 KB Output is correct
65 Correct 16 ms 12984 KB Output is correct
66 Correct 18 ms 12984 KB Output is correct
67 Correct 13 ms 12984 KB Output is correct
68 Correct 13 ms 12984 KB Output is correct
69 Correct 19 ms 12984 KB Output is correct
70 Correct 26 ms 12984 KB Output is correct
71 Correct 171 ms 26548 KB Output is correct
72 Correct 137 ms 28212 KB Output is correct
73 Correct 158 ms 28212 KB Output is correct
74 Correct 116 ms 28212 KB Output is correct
75 Correct 175 ms 28212 KB Output is correct
76 Correct 181 ms 28212 KB Output is correct
77 Correct 81 ms 28212 KB Output is correct
78 Correct 156 ms 28212 KB Output is correct
79 Correct 154 ms 28212 KB Output is correct
80 Correct 140 ms 28212 KB Output is correct
81 Correct 44 ms 28212 KB Output is correct
82 Correct 108 ms 28212 KB Output is correct
83 Correct 149 ms 28212 KB Output is correct
84 Correct 169 ms 28212 KB Output is correct
85 Correct 167 ms 28212 KB Output is correct
86 Correct 156 ms 28212 KB Output is correct
87 Correct 161 ms 28212 KB Output is correct
88 Correct 32 ms 28212 KB Output is correct
89 Correct 91 ms 28212 KB Output is correct
90 Correct 61 ms 28212 KB Output is correct
91 Correct 14 ms 28212 KB Output is correct
92 Correct 59 ms 28212 KB Output is correct