답안 #295437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
295437 2020-09-09T16:42:26 Z Leonardo16 Vision Program (IOI19_vision) C++14
0 / 100
3 ms 1148 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
///=====================================================================


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;
    }

//    cout<<a.fst<<" "<<a.scd<<" "<<b.fst<<" "<<b.scd<<fl;

    int cnt=m*(b.fst-a.fst-1);
    cnt+=m-a.scd;
    cnt+=b.scd;
//    cout<<n-a.scd<<" "<<b.scd<<fl;
    return cnt;
}

vi v;


void count_dist(int n,int m,int k){
    map<int,int>mp;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if( dist( {0,0} , {i,j} ) ==k ){
                mp[ real_dist(n,m,{0,0},{i,j}) ]++;
            }

            if( dist( {n-1,m-1} , {i,j} ) ==k ){
                mp[ real_dist(n,m,{n-1,m-1},{i,j}) ]++;
            }

            if( dist( {n-1,0} , {i,j} ) ==k ){
                mp[ real_dist(n,m,{n-1,0},{i,j}) ]++;
            }

            if( dist( {0,m-1} , {i,j} ) ==k ){
                mp[ real_dist(n,m,{0,m-1},{i,j}) ]++;
            }
        }
    }


    for(auto it:mp){
        if(it.fst>=0){v.pb(it.fst);}
        cout<<it.fst<<fl;
    }

}


void construct_network( int n,int m,int k){
    count_dist(n,m,k);
    int wr=n*m-1;
    for(int i=0;i<n*m;i++){
        for(int j=0;j<v.sz();j++){
            if(i+v[j]<n*m){
                vi nv={i,i+v[j]};
                    add_and(nv);
                wr++;
            }
        }
    }
    vi nv;
    for(int i=n*m;i<=wr;i++){
        nv.pb(i);
    }
    if(nv.sz()==0){
        for(int i=0;i<n*m;i++){
            nv.pb(i);
        }
        add_and(nv);
        return;
    }
    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:105:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |         for(int j=0;j<v.sz();j++){
      |                     ~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB secret mismatch
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB secret mismatch
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB secret mismatch
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB secret mismatch
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB secret mismatch
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB secret mismatch
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1148 KB secret mismatch
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB secret mismatch
2 Halted 0 ms 0 KB -