Skip to content

Instantly share code, notes, and snippets.

@rogerioagjr
Created June 29, 2015 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerioagjr/6ca46797fbf53b720705 to your computer and use it in GitHub Desktop.
Save rogerioagjr/6ca46797fbf53b720705 to your computer and use it in GitHub Desktop.
Caça ao Tesouro (Roger Benet)
#include <cstdio>
#include <algorithm>
#define MAX 110
using namespace std;
int mapa[MAX][MAX];
int n,k;
int main(){
scanf("%d %d", &n, &k);
for(int i = 0; i < k; i++){
int a,b,c,sa,sb,cont;
scanf("%d %d %d", &a, &b, &c);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if( abs(i-a) + abs(j-b) == c ){
mapa[i][j]++;
}
}
}
}
bool ver = false;
int x = -1,y = -1;
for(int i = n-1; i > -1; i--){
for(int j = n-1; j > -1; j--){
if(mapa[i][j] == k){
if(x != -1){
ver = true;
break;
}
x = i;
y = j;
}
}
}
if(ver == false)printf("%d %d\n",x,y);
else printf("-1 -1\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment