Submission #296590

# Submission time Handle Problem Language Result Execution time Memory
296590 2020-09-10T16:49:22 Z Leonardo16 Vision Program (IOI19_vision) C++14
44 / 100
1000 ms 8236 KB
///   Code by Leonardo16
/// “Your focus determines your reality.” – Qui-Gon Jinn
#include<bits/stdc++.h>
#include "vision.h"
using namespace std;
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
//#pragma GCC target("avx2")
//#define int  long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define ii pair<int,int>
#define fst first
#define scd second
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
#define des(x,s1,s2,end1,end2) cout<<((x)?(s1):(s2))<<fl;if(x){end1;}else{end2;}
#define precision(x) cout.setf(ios::fixed);cout.precision(x);
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///=====================================================================

//void add_or(vi v){
//    cout<< "OR : ";
//    for(int i=0;i<v.sz();i++){cout<<v[i]<<" ";}cout<<fl;
//}
//
//void add_xor(vi v){
//    cout<< "XOR : ";
//    for(int i=0;i<v.sz();i++){cout<<v[i]<<" ";}cout<<fl;
//}
//
//void add_and(vi v){
//    cout<< "AND : ";
//    for(int i=0;i<v.sz();i++){cout<<v[i]<<" ";}cout<<fl;
//}


int dist(ii a,ii b){
    return abs(a.fst-b.fst)+abs(a.scd-b.scd);
}

int real_dist(int n,int m,ii a,ii b){
    if(a.fst>b.fst)swap(a,b);

    if(a.fst==b.fst){
        return abs(a.scd-b.scd)+1;
    }

    int cnt=m*(b.fst-a.fst-1);
    cnt+=m-a.scd;
    cnt+=b.scd;
    return cnt;
}

vector<vi> v;

int arr[202][202];

void count_dist(int n,int m,int k){
    int wr=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            arr[i][j]=wr++;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            vi vv;
            for(int h=0;h<n;h++){
                for(int g=0;g<m;g++){
                    if( dist({i,j},{h,g})==k ){
                        vv.pb(arr[h][g]);
                    }
                }
            }
            if(vv.sz()==0)continue;
            v.pb(vv);

            vv.clear();
            vv.pb(arr[i][j]);
            v.pb(vv);
        }
    }

}


void construct_network( int n,int m,int k){
    count_dist(n,m,k);
//    cout<<v.sz()<<fl;
    int wr=n*m-1;
    for(int i=0;i<v.sz();i+=2){
        add_xor(v[i]);
        add_or(v[i+1]);
        wr+=2;
    }


    if(v.sz()==0){
        vi nv;
        for(int i=0;i<n*m;i++){
            nv.pb(i);
        }
        add_and(nv);
        return;
    }

    int ow=wr+1;
    int nw=wr+1;

    for(int i=n*m;i<=wr;i+=2){
        vi nv;
        nv.pb(i);
        nv.pb(i+1);
        add_and(nv);
        nw++;
    }

    vi nv;
    for(int i=ow;i<nw;i++){
        nv.pb(i);
    }
    add_or(nv);
    return;
}


//
//int main(){
//    construct_network(2,3,3);
//}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:116:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  116 |     for(int i=0;i<v.sz();i+=2){
      |                 ~^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 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 384 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 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 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 384 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 256 KB Output is correct
28 Correct 11 ms 1024 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 4 ms 768 KB Output is correct
34 Correct 7 ms 1024 KB Output is correct
35 Correct 6 ms 888 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 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 384 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 256 KB Output is correct
28 Correct 11 ms 1024 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 4 ms 768 KB Output is correct
34 Correct 7 ms 1024 KB Output is correct
35 Correct 6 ms 888 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Incorrect 133 ms 8236 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 504 KB Output is correct
8 Correct 1 ms 496 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 1 ms 372 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 24 ms 1532 KB Output is correct
4 Correct 40 ms 3056 KB Output is correct
5 Correct 36 ms 2304 KB Output is correct
6 Correct 15 ms 1276 KB Output is correct
7 Correct 13 ms 460 KB Output is correct
8 Incorrect 34 ms 1800 KB WA in grader: Too many instructions
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 3532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 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 384 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 256 KB Output is correct
28 Correct 11 ms 1024 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 4 ms 768 KB Output is correct
34 Correct 7 ms 1024 KB Output is correct
35 Correct 6 ms 888 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Incorrect 133 ms 8236 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -