Submission #259743

# Submission time Handle Problem Language Result Execution time Memory
259743 2020-08-08T12:47:09 Z peti1234 Vision Program (IOI19_vision) C++17
29 / 100
12 ms 1408 KB
#include "vision.h"

#include <bits/stdc++.h>

using namespace std;
#define rep(n) for (int i=0; i<n; i++)
#define jrep(n) for (int j=0; j<n; j++)
bool valasz[50005];
const int c=202, f=25;
int pos, ua, nua, v[c], px[c], seg[c], seg2[c], sor[c], oszlop[c], nagy[c], kis[c], ans[c], id;
vector<int> sol;
void pb(int a) {
    sol.push_back(a);
}
int add(int a) {
    pos++;

    if (a==1) add_or(sol);
    if (a==2) add_and(sol);
    if (a==3) add_xor(sol);
    if (a==4) add_not(ua);

/*
    cout << sol.size() << " " << a << "\n";
    rep(sol.size()) cout << sol[i] << " ";
    cout << "\n";
*/
    if (a==4) valasz[pos]=!(valasz[ua]);
    else {
        int si=sol.size(), db=0;
        rep(si) db+=valasz[sol[i]];
        if (a==1) valasz[pos]=(db>0);
        if (a==2) valasz[pos]=(db==si);
        if (a==3) valasz[pos]=(db%2);
    }
    sol.clear();
    return pos;
}
void calc(int n) {
    //cout << "ugyanaz\n";
    int ff=min(n, f);
    rep(n) pb(v[i]);
    ua=add(3), nua=add(4);
    //cout << "bazdmeg " << valasz[ua] << "\n";
    //cout << "prefix xor\n";
    rep(n) {
        if (i) pb(px[i-1]);
        pb(v[i]);
        px[i]=add(3);
    }
    //cout << "nagysag\n";
    for (int j=0; j<n; j+=f) {
        rep(n-j) pb(px[i]), pb(px[i+j]), seg[i]=add(2);
        rep(n-j) pb(seg[i]);
        nagy[j/f]=add(1);
        if (j) pb(nagy[j/f-1]), pb(nagy[j/f]), nagy[j/f-1]=add(3);
    }
    //cout << "mod\n";
    rep(ff) {
        for (int j=i; j<n; j+=f) pb(v[j]);
        seg[i]=add(1);
    }
    //cout << "kis\n";
    rep(ff) {
        if (!i) {
            rep(ff) pb(seg[i]);
            kis[0]=add(3), i++;
            if (i==ff) break;
        }
        jrep(ff-i) pb(seg[j]), pb(seg[j+i]), seg2[j]=add(2);
        jrep(ff-i) pb(seg2[j]);
        kis[i]=add(1);
    }
}
void construct_network(int n, int m, int k) {
    pos=n*m-1;
    //cout << "sor\n";
    rep(n) {
        int p=m*i;
        rep(m) pb(p+i);
        v[i]=add(1);
    }
    calc(n);
    //cout << "melyiksor\n";
    rep(n) {
        if (!i) {
            pb(ua);
            sor[i]=add(1), i++;
            if (n==1) break;
        }
        pb(nua), pb(kis[i%f]), pb(nagy[(i-1)/f]);
        sor[i]=add(2);
    }
    //rep(n) cout << "sor " << valasz[sor[i]] << "\n";
    //cout << "oszlop\n";
    rep(m) {
        int p=i;
        rep(n) pb(p+m*i);
        v[i]=add(1);
    }
    calc(m);
    //cout << "melyikoszlop\n";
    rep(m) {
        if (!i) {
            pb(ua);
            oszlop[i]=add(1), i++;
            if (m==1) break;
        }
        pb(nua), pb(kis[i%f]), pb(nagy[(i-1)/f]);
        oszlop[i]=add(2);
    }
    //rep(m) cout << "oszlop " << valasz[oszlop[i]] << "\n";
    //cout << "osszesitve\n";
    rep(n) {
        int j=k-i;
        if (j>=0 && j<m) pb(sor[i]), pb(oszlop[j]), ans[id]=add(2), id++;
        //if (j>=0 && j<m) cout << "lehet " << i << " " << j << " " << valasz[sor[i]] << " " << valasz[oszlop[j]] << "\n";
    }
    rep(id) pb(ans[i]);
    add(1);
    //cout << "vege\n" << pos << " " << valasz[pos] << "\n";
}









/*
int b1, b2, b3, x, y;
int main()
{
    cin >> b1 >> b2 >> b3 >> x >> y;
    valasz[x]=1, valasz[y]=1;
    construct_network(b1, b2, b3);
    //rep(pos+1) cout << i << " " << valasz[i] << endl;
    cout << valasz[pos] << "\n";
    return 0;
}
*/
/*
2 3 2 0 2
*/
// talán jó
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Incorrect 1 ms 384 KB on inputs (14, 19), (29, 19), expected 1, but computed 0
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Incorrect 1 ms 384 KB on inputs (14, 19), (29, 19), expected 1, but computed 0
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB on inputs (0, 1), (0, 25), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 4 ms 640 KB Output is correct
11 Correct 5 ms 640 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 7 ms 1024 KB Output is correct
21 Correct 7 ms 1024 KB Output is correct
22 Correct 7 ms 1024 KB Output is correct
23 Correct 7 ms 1024 KB Output is correct
24 Correct 7 ms 1024 KB Output is correct
25 Correct 7 ms 1024 KB Output is correct
26 Correct 7 ms 1024 KB Output is correct
27 Correct 12 ms 1408 KB Output is correct
28 Correct 12 ms 1408 KB Output is correct
29 Correct 12 ms 1408 KB Output is correct
30 Correct 12 ms 1408 KB Output is correct
31 Correct 12 ms 1408 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1408 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 2 ms 512 KB on inputs (99, 26), (100, 26), expected 1, but computed 0
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Incorrect 1 ms 384 KB on inputs (14, 19), (29, 19), expected 1, but computed 0
29 Halted 0 ms 0 KB -