Submission #414895

# Submission time Handle Problem Language Result Execution time Memory
414895 2021-05-31T10:21:42 Z David_M Navigation 2 (JOI21_navigation2) C++17
Compilation error
0 ms 0 KB
#include "Anna.h"
#include <bits/stdc++.h>
#define F first
#define S secopnd
#define pb push_back
using namespace std;

int e, E;

int nav(int x1, int y1, int x2, int y2){
	if(abs(x1-x2)<2 && abs(y1-y2)<2){
		for (int i=0; i<7; i++)if(x1+v[i].F==x2 && y1+v[i].S==y2)return i;
	}else{
		if(y1<y2)return 8+1;
		if(y1>y2)return 8+2;
		if(x1<x2)return 8+3;
		if(x1>x2)return 8+4;
	}
}

void Anna(int N, int K, vector<int> R, vector<int> C) {
	
	int f[9];
	
	int a[N][N];
	
	for (int w=0; w<9; w++){
		for (int i=0; i<N; i++){
			for (int j=0; j<N; j++){
				a[w][i][j]=(w+j+3*i+900)%9;
//				cout<<a[w][i][j]<<" ";
			}
//			cout<<endl;
		}
	}
	vector<pair<int, int> > v;
	for (int i=-1; i<=1; i++)for(int j=-1; j<=1; j++)v.pb({i, j});
	v.erase({0, 0});
	
	while(e<9){
		bool u=0;
		for(int i=0; i<K; i++){
			if(a[e][C[i]][R[i]]==i)u=1;
		}
		if(!u){
			for (int i=0; i<9; i++)f[i]=0;
			for (int i=0; i<K; i++){
				for (int j=0; j<8; j++){
					if(a[e][C[i]+v[j].F][R[i]+v[j].S]==i){
						f[j]=1;
					}
				}
			}
			for (int i=0; i<8; i++){
				if(!f[i]){
					E=i;
					break;
				}
			}
			break;	
		}
		e++;
	}
	v.erase(v[E]);
	// 0 E carielebi
	
	for (int r=0; r<N; r++) 
		for (int c=0; c<N; c++){
			if(a[e][r][c]==7)SetFlag(r, c, E);
			if(a[e][r][c]==8)SetFlag(r, c, 0);
    		if(a[e][r][c]<=6)SetFlag(r, c, nav(r, c, R[a[e][r][c]], C[a[e][r][c]]));
    }
  	
  	
}
#include "Bruno.h"
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second

vector<int> Bruno(int K, vector<int> val) {
	
	int r=0;
	vector<int> V;
	for (int i=0; i<9; i++){
		if(val[i]==8){
			r=i;
			break;
		}
	}
	for (int i=r+1; i<r+10; i++){
		V.pb({v[i%9], i%9});
	}
	
	for (int i=-1; i<=1; i++){
		for (int j=-1; j<=1; j++){
			v.pb({i, j});
		}
	}
	v.erase({0, 0});
	v.erase(V[7]);
	for (int i=0; i<7; i++){
		if(V[i].F>8)Ans.pb(V[i].F-9);
		else{
			int r1=1, c1=1;
			int r2=V[i].S/3, c2=V[i].S%3;
			r2+=v[i].F;
			c2+=v[i].S;
			if(r1==c1 && r2==c2)Ans.pb(4);
			else if(c1>c2)Ans.pb(0);
			else if(c1<c2)Ans.pb(1);
			else if(r1<r2)Ans.pb(2);
			else if(r1>r2)Ans.pb(3);
		}
	}

	return Ans;
}

Compilation message

Anna.cpp: In function 'int nav(int, int, int, int)':
Anna.cpp:12:32: error: 'v' was not declared in this scope
   12 |   for (int i=0; i<7; i++)if(x1+v[i].F==x2 && y1+v[i].S==y2)return i;
      |                                ^
Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:30:12: error: invalid types 'int[int]' for array subscript
   30 |     a[w][i][j]=(w+j+3*i+900)%9;
      |            ^
Anna.cpp:38:16: error: no matching function for call to 'std::vector<std::pair<int, int> >::erase(<brace-enclosed initializer list>)'
   38 |  v.erase({0, 0});
      |                ^
In file included from /usr/include/c++/10/vector:67,
                 from Anna.h:1,
                 from Anna.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::pair<int, int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::pair<int, int> >::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::pair<int, int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::pair<int, int> >::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
Anna.cpp:43:17: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   43 |    if(a[e][C[i]][R[i]]==i)u=1;
      |                 ^
Anna.cpp:4:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'secopnd'; did you mean 'second'?
    4 | #define S secopnd
      |           ^~~~~~~
Anna.cpp:49:37: note: in expansion of macro 'S'
   49 |      if(a[e][C[i]+v[j].F][R[i]+v[j].S]==i){
      |                                     ^
Anna.cpp:64:14: error: no matching function for call to 'std::vector<std::pair<int, int> >::erase(__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type&)'
   64 |  v.erase(v[E]);
      |              ^
In file included from /usr/include/c++/10/vector:67,
                 from Anna.h:1,
                 from Anna.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::pair<int, int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::pair<int, int> >::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::pair<int, int> >::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::pair<int, int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::pair<int, int> >::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
Anna.cpp:69:14: error: invalid types 'int[int]' for array subscript
   69 |    if(a[e][r][c]==7)SetFlag(r, c, E);
      |              ^
Anna.cpp:70:14: error: invalid types 'int[int]' for array subscript
   70 |    if(a[e][r][c]==8)SetFlag(r, c, 0);
      |              ^
Anna.cpp:71:17: error: invalid types 'int[int]' for array subscript
   71 |       if(a[e][r][c]<=6)SetFlag(r, c, nav(r, c, R[a[e][r][c]], C[a[e][r][c]]));
      |                 ^
Anna.cpp:71:57: error: invalid types 'int[int]' for array subscript
   71 |       if(a[e][r][c]<=6)SetFlag(r, c, nav(r, c, R[a[e][r][c]], C[a[e][r][c]]));
      |                                                         ^
Anna.cpp:71:72: error: invalid types 'int[int]' for array subscript
   71 |       if(a[e][r][c]<=6)SetFlag(r, c, nav(r, c, R[a[e][r][c]], C[a[e][r][c]]));
      |                                                                        ^
Anna.cpp: In function 'int nav(int, int, int, int)':
Anna.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^

Bruno.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> Bruno(int K, vector<int> val) {
      | ^~~~~~