답안 #238423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238423 2020-06-11T07:49:03 Z Ruxandra985 Vision Program (IOI19_vision) C++14
14 / 100
31 ms 2176 KB
#include <bits/stdc++.h>
#include <cassert>
#include <string>
#include "vision.h"


using namespace std;


/// ---------------------------------------------------------------------------------

int res[1000010] , f[210][210];
int sau_pr[510] , sau_sec[510] , xor_pr[510] , xor_sec[510];

int convert (int x , int y , int n , int m){

    return (x - 1) * m + y - 1;

}

int in_matrix (int i , int j , int n , int m){

    return (i > 0 && j > 0 && i <= n && j <= m);

}


void construct_network(int n, int m, int k) {

    int i , j , dif , dif2 , sum , sum2 , princ , sec , rez1 , rez2 , cod_diag , p1 , p2;
    vector <int> v , w , x;
    for (dif = 1 - m ; dif <= n - 1 ; dif++){

        v.clear();

        for (i = 1 ; i <= n ; i++){

            /// i - j = dif
            j = i - dif;

            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta

                v.push_back(convert(i , j , n , m));

            }


        }


        /// in v ai elem de pe diag
        cod_diag = dif - (1 - m);
        sau_pr[cod_diag] = add_or(v);
        xor_pr[cod_diag] = add_xor(v);

    }
    w.clear();
    for (dif = 1 - m ; dif <= n - 1 ; dif++){
        v.clear();
        x.clear();

        if (dif + k > n - 1)
            continue;

        for (dif2 = dif ; dif2 <= n - 1 && dif2 <= dif + k ; dif2++){

            /// vad intervalul dif , dif2
            v.push_back(sau_pr[dif2 - (1 - m)]);
            x.push_back(xor_pr[dif2 - (1 - m)]);
        }


        p1 = add_or(v);
        p2 = add_xor(x);

        v.clear();
        v.push_back(p1);
        v.push_back(p2);

        w.push_back(add_xor(v));

    }

    princ = add_or(w);


    /// pe princ trb sa fie 1
    /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    for (sum = n + m ; sum >= 2 ; sum--){

        v.clear();

        for (i = 1 ; i <= n ; i++){

            /// i + j = sum
            j = - (i - sum);

            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta

                v.push_back(convert(i , j , n , m));

            }


        }

        /// in v ai elem de pe diag
        cod_diag = sum;
        sau_sec[cod_diag] = add_or(v);
        xor_sec[cod_diag] = add_xor(v);

    }

    w.clear();
    for (sum = n + m ; sum >= 2 ; sum--){
        v.clear();
        x.clear();

        for (sum2 = sum ; sum2 >= 2 && sum - sum2 <= k ; sum2--){

            /// vad intervalul sum , sum2
            v.push_back(sau_sec[sum2]);
            x.push_back(xor_sec[sum2]);
        }

        p1 = add_or(v);
        p2 = add_xor(x);

        v.clear();
        v.push_back(p1);
        v.push_back(p2);

        w.push_back(add_xor(v));

    }

    sec = add_or(w);

    v.clear();
    v.push_back(princ);
    v.push_back(sec);

    rez1 = add_and(v);
    if (k == 1)
        return;

    /// ----------------------------------------------------------------------------


    for (dif = 1 - m ; dif <= n - 1 ; dif++){

        v.clear();

        for (i = 1 ; i <= n ; i++){

            /// i - j = dif
            j = i - dif;

            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta

                v.push_back(convert(i , j , n , m));

            }


        }

        /// in v ai elem de pe diag
        cod_diag = dif - (1 - m);
        sau_pr[cod_diag] = add_or(v);
        xor_pr[cod_diag] = add_xor(v);

    }
    w.clear();
    for (dif = 1 - m ; dif <= n - 1 ; dif++){
        v.clear();
        x.clear();

        for (dif2 = dif ; dif2 <= n - 1 && dif2 < dif + k ; dif2++){

            /// vad intervalul dif , dif2
            v.push_back(sau_pr[dif2 - (1 - m)]);
            x.push_back(xor_pr[dif2 - (1 - m)]);
        }

        p1 = add_or(v);
        p2 = add_xor(x);

        v.clear();
        v.push_back(p1);
        v.push_back(p2);

        w.push_back(add_xor(v));

    }

    princ = add_or(w);
    /// pe princ trb sa fie 1
    /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    for (sum = n + m ; sum >= 2 ; sum--){

        v.clear();

        for (i = 1 ; i <= n ; i++){

            /// i + j = sum
            j = - (i - sum);

            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta

                v.push_back(convert(i , j , n , m));

            }


        }

        /// in v ai elem de pe diag
        cod_diag = sum;
        sau_sec[cod_diag] = add_or(v);
        xor_sec[cod_diag] = add_xor(v);

    }
    w.clear();
    for (sum = n + m ; sum >= 2 ; sum--){
        v.clear();
        x.clear();

        for (sum2 = sum ; sum2 >= 2 && sum - sum2 < k ; sum2--){

            /// vad intervalul sum , sum2
            v.push_back(sau_sec[sum2]);
            x.push_back(xor_sec[sum2]);
        }

        p1 = add_or(v);
        p2 = add_xor(x);

        v.clear();
        v.push_back(p1);
        v.push_back(p2);

        w.push_back(add_xor(v));

    }



    sec = add_or(w);

    v.clear();
    v.push_back(princ);
    v.push_back(sec);

    rez2 = add_and(v);


    rez2 = not(rez2);

    v.clear();
    v.push_back(rez1);
    v.push_back(rez2);
    add_and(v);


}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Incorrect 17 ms 1536 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 2172 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Correct 8 ms 640 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 19 ms 1280 KB Output is correct
8 Correct 14 ms 1280 KB Output is correct
9 Correct 25 ms 2176 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -