Submission #918770

# Submission time Handle Problem Language Result Execution time Memory
918770 2024-01-30T12:05:38 Z alexander707070 Navigation 2 (JOI21_navigation2) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "Anna.h"
using namespace std;

namespace{
vector< pair<int,int> > calc={ {0,0},{0,1},{0,2},{1,0},{1,1},{1,2},{2,0} };
}

void Anna(int N, int K, vector<int> R, vector<int> C) {
    for(int t=0;t<K;t++){
        for(int i=0;i<N;i+=3){
            for(int f=0;f<N;f+=3){
                if(R[t]/3<i/3)SetFlag(i+calc[t].first, f+calc[t].second, 1);
                else if(R[t]/3>i/3)SetFlag(i+calc[t].first, f+calc[t].second, 2);
                else if(C[t]/3<f/3)SetFlag(i+calc[t].first, f+calc[t].second, 3);
                else if(C[t]/3>f/3)SetFlag(i+calc[t].first, f+calc[t].second, 4);
                else{
                    if(R[t]==i and C[t]==f)SetFlag(i+calc[t].first, f+calc[t].second, 5);
                    if(R[t]==i and C[t]==f+1)SetFlag(i+calc[t].first, f+calc[t].second, 6);
                    if(R[t]==i and C[t]==f+2)SetFlag(i+calc[t].first, f+calc[t].second, 7);

                    if(R[t]==i+1 and C[t]==f)SetFlag(i+calc[t].first, f+calc[t].second, 8);
                    if(R[t]==i+1 and C[t]==f+1)SetFlag(i+calc[t].first, f+calc[t].second, 9);
                    if(R[t]==i+1 and C[t]==f+2)SetFlag(i+calc[t].first, f+calc[t].second, 10);

                    if(R[t]==i+2 and C[t]==f)SetFlag(i+calc[t].first, f+calc[t].second, 11);
                    if(R[t]==i+2 and C[t]==f+1)SetFlag(i+calc[t].first, f+calc[t].second, 12);
                    if(R[t]==i+2 and C[t]==f+2)SetFlag(i+calc[t].first, f+calc[t].second, 13);
                }
            }
        }
    }

    for(int i=0;i<N;i+=3){
        for(int f=0;f<N;f+=3){
            if(i+2<N and f+1<N)SetFlag(i+2,f+1,14);
            if(i+2<N and f+2<N)SetFlag(i+2,f+2,14);
        }
    }
}
#include<bits/stdc++.h>
#include "Bruno.h"
using namespace std;

namespace{
int table[4][4],to[4][4];
int num[8],shiftx,shifty,x,y;
int where[4][4];

int sample[8][8];
vector<int> sol;
}

vector<int> Bruno(int K, vector<int> value) {
    for(int i=1;i<=6;i+=3){
        for(int f=1;f<=6;f+=3){
            sample[i][f]=1;
            sample[i][f+1]=2;
            sample[i][f+2]=3;

            sample[i+1][f]=4;
            sample[i+1][f+1]=5;
            sample[i+1][f+2]=6;

            sample[i+2][f]=7;
            sample[i+2][f+1]=-1;
            sample[i+2][f+2]=-1;
        }
    }

    for(int i=0;i<value.size();i++){
        table[i/3+1][i%3+1]=value[i];
    }

    for(int i=1;i<=3;i++){
        for(int f=1;f<=3;f++){
            bool dali=true;

            for(int k=1;k<=3;k++){
                for(int t=1;t<=3;t++){
                    if(table[k][t]==14 and sample[i+k-1][f+t-1]!=-1)dali=false;
                }
            }

            if(!dali)continue;

            shiftx=-(i-1)-1;
            shifty=-(f-1)-1;
            for(int k=1;k<=3;k++){
                for(int t=1;t<=3;t++){
                    to[k][t]=sample[i+k-1][f+t-1];
                    if(i+k-1<=3 and f+t-1<=3)where[k][t]=0;
                    if(i+k-1<=3 and f+t-1>3)where[k][t]=1;
                    if(i+k-1>3 and f+t-1<=3)where[k][t]=2;
                    if(i+k-1>3 and f+t-1>3)where[k][t]=3;
                }
            }
        }
    }

    for(int t=1;t<=K;t++){
        int res=0,x=2,y=2,ans=0;
        int xx=shiftx,yy=shifty;

        for(int i=1;i<=3;i++){
            for(int f=1;f<=3;f++){
                if(to[i][f]==t){
                    res=table[i][f];
                    if(where[i][f]==1)yy+=3;
                    if(where[i][f]==2)xx+=3;
                    if(where[i][f]==3){xx+=3;yy+=3;}
                }
            }
        }

        if(res==1)ans=3;
        else if(res==2)ans=2;
        else if(res==3)ans=1;
        else if(res==4)ans=0;
        else{
            if(res==5){x=0+xx;y=0+yy;}
            if(res==6){x=0+xx;y=1+yy;}
            if(res==7){x=0+xx;y=2+yy;}

            if(res==8){x=1+xx;y=0+yy;}
            if(res==9){x=1+xx;y=1+yy;}
            if(res==10){x=1+xx;y=2+yy;}

            if(res==11){x=2+xx;y=0+yy;}
            if(res==12){x=2+xx;y=1+yy;}
            if(res==13){x=2+xx;y=2+yy;}

            if(x<0)ans=3;
            else if(x>0)ans=2;
            else if(y<0)ans=1;
            else if(y>0)ans=0;
            else ans=4;
        }

        sol.push_back(ans);
    }

    return sol;

}

/*
1
9 7
1 4
2 7
3 1
4 6
5 3
6 2
7 5
4 4
*/

Compilation message

Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:17:13: error: reference to 'sample' is ambiguous
   17 |             sample[i][f]=1;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:18:13: error: reference to 'sample' is ambiguous
   18 |             sample[i][f+1]=2;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:19:13: error: reference to 'sample' is ambiguous
   19 |             sample[i][f+2]=3;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:21:13: error: reference to 'sample' is ambiguous
   21 |             sample[i+1][f]=4;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:22:13: error: reference to 'sample' is ambiguous
   22 |             sample[i+1][f+1]=5;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:23:13: error: reference to 'sample' is ambiguous
   23 |             sample[i+1][f+2]=6;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:25:13: error: reference to 'sample' is ambiguous
   25 |             sample[i+2][f]=7;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:26:13: error: reference to 'sample' is ambiguous
   26 |             sample[i+2][f+1]=-1;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:27:13: error: reference to 'sample' is ambiguous
   27 |             sample[i+2][f+2]=-1;
      |             ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<value.size();i++){
      |                 ~^~~~~~~~~~~~~
Bruno.cpp:41:44: error: reference to 'sample' is ambiguous
   41 |                     if(table[k][t]==14 and sample[i+k-1][f+t-1]!=-1)dali=false;
      |                                            ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp:51:30: error: reference to 'sample' is ambiguous
   51 |                     to[k][t]=sample[i+k-1][f+t-1];
      |                              ^~~~~~
Bruno.cpp:10:5: note: candidates are: 'int {anonymous}::sample [8][8]'
   10 | int sample[8][8];
      |     ^~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:5854:5: note:                 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5854 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
Bruno.cpp: At global scope:
Bruno.cpp:10:5: warning: '{anonymous}::sample' defined but not used [-Wunused-variable]
   10 | int sample[8][8];
      |     ^~~~~~
Bruno.cpp:7:28: warning: '{anonymous}::y' defined but not used [-Wunused-variable]
    7 | int num[8],shiftx,shifty,x,y;
      |                            ^
Bruno.cpp:7:26: warning: '{anonymous}::x' defined but not used [-Wunused-variable]
    7 | int num[8],shiftx,shifty,x,y;
      |                          ^
Bruno.cpp:7:5: warning: '{anonymous}::num' defined but not used [-Wunused-variable]
    7 | int num[8],shiftx,shifty,x,y;
      |     ^~~