Submission #873634

# Submission time Handle Problem Language Result Execution time Memory
873634 2023-11-15T12:11:54 Z andrei_boaca Vision Program (IOI19_vision) C++17
66 / 100
93 ms 9968 KB
#include "vision.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;

vector<int> lins,cols;
vector<int> dlin[505],dcol[505];
int d1[505],d2[505],ind;
void construct_network(int H, int W, int K)
{
    if(min(H,W)==1)
    {
        H=max(H,W);
        vector<int> v;
        int cnt=0;
        for(int i=0;i+K<H;i++)
        {
            v={i,i+K};
            add_and(v);
            cnt++;
        }
        v.clear();
        for(int i=H;i<H+cnt;i++)
            v.push_back(i);
        assert(v.size()==cnt);
        add_or(v);
        return;
    }
    ind=H*W-1;
    if(max(H,W)<=30||K>70)
    {
        vector<int> cand;
        int cnt=0;
        for(int i=0;i<H;i++)
            for(int j=0;j<W;j++)
            {
                vector<int> v;
                for(int l=0;l<H;l++)
                {
                    int need=K-abs(l-i);
                    if(need<0)
                        continue;
                    int c=j+need;
                    if(c>=0&&c<W)
                        v.push_back(l*W+c);
                    c=j-need;
                    if(c>=0&&c<W&&need!=0)
                        v.push_back(l*W+c);
                }
                if(cnt<9997&&!v.empty())
                {
                    ind++;
                    add_or(v);
                    cnt++;

                    vector<int> t={ind,i*W+j};
                    add_and(t);
                    cnt++;
                    ind++;
                    cand.push_back(ind);
                }
            }
        add_or(cand);
        return;
    }
    for(int i=0;i<H;i++)
    {
        vector<int> v;
        for(int j=0;j<W;j++)
            v.push_back(i*W+j);
        add_or(v);
        ind++;
        lins.push_back(ind);
    }
    for(int j=0;j<W;j++)
    {
        vector<int> v;
        for(int i=0;i<H;i++)
            v.push_back(i*W+j);
        add_or(v);
        ind++;
        cols.push_back(ind);
    }
    for(int i=0;i<H;i++)
        for(int j=i+1;j<H&&j-i<=min(K,70);j++)
        {
            vector<int> v={lins[i],lins[j]};
            add_and(v);
            ind++;
            dlin[j-i].push_back(ind);
        }
    for(int i=0;i<W;i++)
        for(int j=i+1;j<W&&j-i<=min(K,70);j++)
        {
            vector<int> v={cols[i],cols[j]};
            add_and(v);
            ind++;
            dcol[j-i].push_back(ind);
        }
    vector<int> a;
    for(int d=1;d<=H-1&&d<=min(K,70);d++)
    {
        ind++;
        add_or(dlin[d]);
        d1[d]=ind;
        a.push_back(ind);
    }
    a.clear();
    for(int d=1;d<=W-1&&d<=min(K,70);d++)
    {
        ind++;
        add_or(dcol[d]);
        d2[d]=ind;
        a.push_back(ind);
    }
    a.clear();
    for(int i=0;i+1<H;i++)
    {
        vector<int> v;
        for(int j=i+1;j<H;j++)
            v.push_back(lins[j]);
        ind++;
        add_or(v);
        vector<int> p={ind,lins[i]};
        add_and(p);
        ind++;
        a.push_back(ind);
    }
    add_or(a);
    ind++;
    add_not(ind);
    ind++;
    d1[0]=ind;

    a.clear();
    for(int i=0;i+1<W;i++)
    {
        vector<int> v;
        for(int j=i+1;j<W;j++)
            v.push_back(cols[j]);
        ind++;
        add_or(v);
        vector<int> p={ind,cols[i]};
        add_and(p);
        ind++;
        a.push_back(ind);
    }
    add_or(a);
    ind++;
    add_not(ind);
    ind++;
    d2[0]=ind;
    vector<int> cand;
    for(int x=0;x<=H-1;x++)
        for(int y=0;y<=W-1;y++)
            if(x+y==K&&d1[x]!=-1&&d2[y]!=-1)
            {
                vector<int> v={d1[x],d2[y]};
                add_and(v);
                ind++;
                cand.push_back(ind);
            }
    add_or(cand);
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from vision.cpp:2:
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:25:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         assert(v.size()==cnt);
      |                ~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 3 ms 600 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 4 ms 604 KB Output is correct
35 Correct 3 ms 604 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 3 ms 600 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 4 ms 604 KB Output is correct
35 Correct 3 ms 604 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 7 ms 1492 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 3 ms 604 KB Output is correct
44 Correct 7 ms 1492 KB Output is correct
45 Incorrect 33 ms 4028 KB on inputs (55, 92), (81, 18), expected 1, but computed 0
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 4 ms 984 KB Output is correct
6 Correct 4 ms 812 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 5 ms 1220 KB Output is correct
10 Correct 21 ms 2720 KB Output is correct
11 Correct 8 ms 1236 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 6 ms 1116 KB Output is correct
21 Correct 55 ms 6088 KB Output is correct
22 Correct 35 ms 4044 KB Output is correct
23 Correct 6 ms 452 KB Output is correct
24 Correct 6 ms 1116 KB Output is correct
25 Correct 45 ms 5368 KB Output is correct
26 Correct 3 ms 344 KB Output is correct
27 Correct 10 ms 1664 KB Output is correct
28 Correct 91 ms 8904 KB Output is correct
29 Correct 93 ms 9968 KB Output is correct
30 Correct 36 ms 3272 KB Output is correct
31 Correct 13 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1628 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 6 ms 1116 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1868 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 3 ms 600 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 4 ms 604 KB Output is correct
35 Correct 3 ms 604 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 7 ms 1492 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 3 ms 604 KB Output is correct
44 Correct 7 ms 1492 KB Output is correct
45 Incorrect 33 ms 4028 KB on inputs (55, 92), (81, 18), expected 1, but computed 0
46 Halted 0 ms 0 KB -