Problem:
Problem E:
Beehives
Taro and Hanako, students majoring in biology, have been engaged long in observations of beehives. Their interest is in finding any egg patterns laid by queen bees of a specific wild species. A queen bee is said to lay a batch ofeggs in a short time. Taro and Hanako have never seen queen bees laying eggs. Thus, every time they find beehives, they find eggs just laid in hive cells.
Taro and Hanako have a convention to record an egg layout.. they assume the queen bee lays eggs, moving from one cell to an adjacent cell along a path containing no cycles. They record the path of cells with eggs. There is no guarantee in biology for them to find an acyclic path in every case. Yet they have never failed to do so in their observations.
There are only six possible movements from a cell to an adjacent one, and they agree to write down those six by letters a, b, c, d, e, and f ounterclockwise as shown in Figure 2. Thus the layout in Figure 1 may be written down as "faafd".
Taro and Hanako have investigated beehives in a forest independently. Each has his/her own way to approach beehives, protecting oneself from possible bee attacks.
They are asked to report on their work jointly at a conference, and share their own observation records to draft a joint report. At this point they find a serious fault in their convention. They have never discussed which direction, in an absolute sense, should be taken as "a", and thus Figure 2 might be taken as, e.g., Figure 3 or Figure 4. The layout shown in Figure 1 may be recorded differently, depending on the direction looking at the beehive and the path assumed: "bcbdb" with combination of Figure 3 and Figure 5, or "bccac" with combination of Figure 4 and Figure 6.
A beehive can be observed only from its front side and never from its back, so a layout cannot be confused with its mirror image.
Since they may have observed the same layout independently, they have to find duplicated records in their observations (Of course, they do not record the exact place and the exact time of each observation). Your mission is to help Taro and Hanako by writing a program that checks whether two observation records are made from the same layout.
Input
The input starts with a line containing the number of record pairs that follow. The number is given with at most three digits.
Each record pair consists of two lines of layout records and a line containing a hyphen. Each layout record consists of a sequence of letters a, b, c, d, e, and f. Note that a layout record may be an empty sequence if a queen bee laid only one egg by some reason. You can trust Taro and Hanako in that any of the paths in the input does not force you to visit any cell more than once. Any of lines in the input contain no characters other than those described above, and contain at most one hundred characters.
Output
For each pair of records, produce a line containing either "
true
" or "
false
": "
true
" if the two records represent the same layout, 
...(truncated)

Submitted solutions:

code_snippet: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


string line;

struct Info{
	Info(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

char buf1[101],buf2[101],buf3[101];
bool table1[201][201],table2[201][201];
int len_1,len_2,start_row = 100,start_col = 100,G[128];
int diff_row[6] = {1,1,0,-1,-1,0},diff_col[6] = {0,-1,-1,0,1,1};
int loc[6][6] = {{0,1,2,3,4,5},{1,2,3,4,5,0},{2,3,4,5,0,1},{3,4,5,0,1,2},{4,5,0,1,2,3},{5,0,1,2,3,4}};
vector<Info> V;

void func(){

	getchar();
	getline(cin,line);
	for(len_1 = 0; len_1 != line.length(); len_1++){
		buf1[len_1] = line[len_1];
	}
	buf1[len_1] = '\0';

	getline(cin,line);
	for(len_2 = 0; len_2 != line.length(); len_2++){
		buf2[len_2] = line[len_2];
	}
	buf2[len_2] = '\0';
	scanf("%s",buf3);

	for(len_1 = 0; buf1[len_1] != '\0'; len_1++);
	for(len_2 = 0; buf2[len_2] != '\0'; len_2++);

	if(len_1 != len_2){
		printf("false\n");
		return;
	}else if(len_1 == 0 && len_2 == 0){
		printf("true\n");
		return;
	}

	for(int row = 0; row <= 200; row++){
		for(int col = 0; col <= 200; col++){
			table1[row][col] = false;
			table2[row][col] = false;
		}
	}

	V.clear();

	int tmp_row = start_row,tmp_col = start_col,tmp;
	table1[start_row][start_col] = true;
	V.push_back(Info(start_row,start_col));

	for(int i = 0; i < len_1; i++){
		tmp = G[buf1[i]];
		tmp_row += diff_row[tmp];
		tmp_col += diff_col[tmp];
		table1[tmp_row][tmp_col] = true;
		V.push_back(Info(tmp_row,tmp_col));
	}

	bool FLG;
	vector<Info> X;

	for(int loop = 0; loop < V.size();  loop++){

		for(int k = 0; k < 6; k++){

			for(int i = 0; i < X.size(); i++){
				table2[X[i].row][X[i].col] = false;
			}
			X.clear();

			tmp_row = V[loop].row;
			tmp_col = V[loop].col;
			table2[tmp_row][tmp_col] = true;
			X.push_back(Info(tmp_row,tmp_col));

			FLG = true;
			for(int i = 0; i < len_2; i++){

				tmp = loc[k][G[buf2[i]]];
				tmp_row += diff_row[tmp];
				tmp_col += diff_col[tmp];
				if(table1[tmp_row][tmp_col] == false){
					FLG = false;
					break;
				}
				table2[tmp_row][tmp_col] = true;
				X.push_back(Info(tmp_row,tmp_col));
			}
			if(!FLG)continue;

			for(int i = 0; i < V.size(); i++){
				if(table2[V[i].row][V[i].col] == false){
					FLG = false;
					break;
				}
			}
			if(FLG){
				printf("true\n");
				return;
			}
		}
	}
	printf("false\n");
}


int main(){

	int case_num;
	scanf("%d",&case_num);

	G['a'] = 0;
	G['b'] = 1;
	G['c'] = 2;
	G['d'] = 3;
	G['e'] = 4;
	G['f'] = 5;

	for(int i = 0; i < case_num; i++)func();

	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3324
final_rank: 17

code_snippet: #include <bits/stdc++.h>
 
using namespace std;
 
const int dx[] = {0, 1, 1, 0, -1, -1};
const int dy[] = {-1, 0, 1, 1, 0, -1};
 
using Point = pair<int, int>;
 
int main() {
  int T;
  cin >> T;
  cin.ignore();  
  while(T--) {
    string s, t, sp;    
    //cin >> s >> t >> sp;
    getline(cin, s);
    getline(cin, t);
    getline(cin, sp);
    if(s.size() != t.size()) {
      cout << "false" << endl;
      continue;
    }
    int x = 0, y = 0;
    set<Point> vis;
    vis.insert(Point(0, 0));
    for(char c : s) {
      int k = c-'a';
      x += dx[k], y += dy[k];
      vis.insert(Point(x, y));
    }
    for(int i = 0; i < 6; i++) {
      for(Point p : vis) {
    set<Point> st;
    int x = p.first, y = p.second;
    st.insert(Point(x, y));
    for(char c : t) {
      int k = c-'a';
      x += dx[(k+i)%6], y += dy[(k+i)%6];
      if(!vis.count(Point(x, y))) {
        break;
      } else {
        st.insert(Point(x, y));
      }
    }
    if(st == vis) {
      cout << "true" << endl;
      goto end;
    }
      }
    }
    cout << "false" << endl;
  end: ;
  }
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3156
final_rank: 15

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
string s,t;
int n;
int dy1[6]={1,1,0,-1,-1,0};
int dx1[6]={0,-1,-1,0,1,1};
int dy2[6]={-1,-1,0,1,1,0};
int dx2[6]={0,1,1,0,-1,-1};
bool b[1000][1000];
bool c[1000][1000];
main(){
  cin>>n;
  while(n--){
    memset(b,0,sizeof(b));
    cin>>s;
    if(s=="-"){
      cout<<"true"<<endl;
      continue;
    }
    int y=500,x=500;
    b[y][x]=1;
    vector<int>X,Y;
    X.push_back(x);
    Y.push_back(y);
    rep(i,s.size()){
      x+=dx1[s[i]-'a'];
      y+=dy1[s[i]-'a'];
      b[y][x]=1;
      X.push_back(x);
      Y.push_back(y);
    }
    cin>>t;
    if(t=="-"){
      cout<<"false"<<endl;
      continue;
    }
    rep(i,2){
      rep(j,6){
        rep(l,X.size()){
          int f=0,y=Y[l],x=X[l];
          rep(k,t.size()){
            if(i){
              x+=dx2[(t[k]-'a'+j)%6];
              y+=dy2[(t[k]-'a'+j)%6];
            }else{
              x+=dx1[(t[k]-'a'+j)%6];
              y+=dy1[(t[k]-'a'+j)%6];
            }
            if(b[y][x])f++;
          }
          if(f==t.size())goto L;
        }
      }
      reverse(t.begin(),t.end());
    }
    cout<<"false"<<endl;
    if(0){L:;cout<<"true"<<endl;}
    cin>>s;
  }
}
accuracy: 1
time_ms: 50
memory_kb: 4140
final_rank: 18

code_snippet: #include <bits/stdc++.h>

using namespace std;

const int dx[] = {0, 1, 1, 0, -1, -1};
const int dy[] = {-1, 0, 1, 1, 0, -1};

using Point = pair<int, int>;

int main() {
  int T;
  cin >> T;
  cin.ignore();  
  while(T--) {
    string s, t, sp;    
    //cin >> s >> t >> sp;
    getline(cin, s);
    getline(cin, t);
    getline(cin, sp);
    if(s.size() != t.size()) {
      cout << "false" << endl;
      continue;
    }
    int x = 0, y = 0;
    set<Point> vis;
    vis.insert(Point(0, 0));
    for(char c : s) {
      int k = c-'a';
      x += dx[k], y += dy[k];
      vis.insert(Point(x, y));
    }
    for(int i = 0; i < 6; i++) {
      for(Point p : vis) {
	set<Point> st;
	int x = p.first, y = p.second;
	st.insert(Point(x, y));
	for(char c : t) {
	  int k = c-'a';
	  x += dx[(k+i)%6], y += dy[(k+i)%6];
	  if(!vis.count(Point(x, y))) {
	    break;
	  } else {
	    st.insert(Point(x, y));
	  }
	}
	if(st == vis) {
	  cout << "true" << endl;
	  goto end;
	}
      }
    }
    cout << "false" << endl;
  end: ;
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3172
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;

int dy[6]={1,1,0,-1,-1,0};
int dx[6]={0,-1,-1,0,1,1};

int base[1000][1000];
int cnum[300];
char cc[300];

int main(){

  cnum['a']=0;
  cnum['b']=1;
  cnum['c']=2;
  cnum['d']=3;
  cnum['e']=4;
  cnum['f']=5;
  
  cc['a']='d';
  cc['b']='e';
  cc['c']='f';
  cc['d']='a';
  cc['e']='b';
  cc['f']='c';
  
  int n;

  cin>>n;
  
  while(n--){
    
    string s;
    string t;
    
    cin>>s;
    
    if(s=="-"){
      cout<<"true"<<endl;
      continue;
    }

    vector<int> X, Y;
    
    int y=500, x=500;

    memset(base,0,sizeof(base));

    base[y][x]=1;
    X.push_back(x);
    Y.push_back(y);
    
    for(int i=0;i<s.size();i++){
      
      y+=dy[cnum[s[i]]];
      x+=dx[cnum[s[i]]];

      base[y][x]=1;
      X.push_back(x);
      Y.push_back(y);
    }

    cin>>t;
    
    if(t=="-"){
      cout<<"false"<<endl;
      continue;
    }
    
    bool ans=false;
      
    for(int T=0;T<X.size();T++){
        
      for(int i=0;i<6;i++){

	
	int flag=0;

	y=Y[T], x=X[T];
      
	for(int j=0;j<t.size();j++){
      
	  y+=dy[(cnum[t[j]]+i)%6];
	  x+=dx[(cnum[t[j]]+i)%6];
	
	  if(!base[y][x]) flag=1;
	}
      
	if(!flag) ans=true;
      
      }

      reverse(t.begin(),t.end());
    
      for(int i=0;i<6;i++){
      
	int flag=0;
      
	y=Y[T], x=X[T];
	
	for(int j=0;j<t.size();j++){
	
	  y+=dy[(cnum[cc[t[j]]]+i)%6];
	  x+=dx[(cnum[cc[t[j]]]+i)%6];
	
	  if(!base[y][x]) flag=1;
	}

	if(!flag) ans=true;
      
      }
      
      reverse(t.begin(),t.end());

    }
    
    if(s.size()!=t.size()) ans=false;

    if(ans) cout<<"true"<<endl;
    else cout<<"false"<<endl;
    
    cin>>s;
  }
  
  return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 7056
final_rank: 19

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
vector<int> ss(string&s ){
  vector<int> v;
  for(int i=0;i<(int)s.size();i++){
    v.push_back( s[i] - 'a' );
  }
  return v;
}

int dx[2][6]={ {0,-1,-1,0,1,1},
               {0,1,1,0,-1,-1} };
int dy[2][6]={ {1,1,0,-1,-1,0},
               {1,0,-1,-1,0,1} };

void dfs(int x,int y,int c,int k,const vector<int>& v,set<P> &s){
  s.insert(P(x,y));
  if( c == (int)v.size() ) return;
  int d = (v[c]+k)%6;
  dfs( x + dx[0][d], y + dy[0][d], c+1, k, v, s );
}

bool eq(const set<P>& a, const set<P>& b){
  if(a.size() != b.size() ) return false;
  for( auto x = a.begin(), y = b.begin(); x != a.end() || y != b.end(); x++, y++ )
    if( *x != *y ) return false;
  return true;
}

void view(const set<P> &s ){
  for( auto x : s ){
    cout << x.first << " " <<x.second << endl;
  }
}

int main(){

  int T;
  cin >> T;
  getchar();
  while(T--){
    string S1,S2; 
    getline(cin,S1);
    getline(cin,S2);
    vector<int> v1 = ss( S1 ), v2 = ss( S2 );
    getline(cin,S1);   
    bool f = false;
    for(int i=0;i<6;i++){
      set<P> s1;
      dfs( 0,0,0,i,v1,s1 );
      //cout << "s1------------- "<< endl;
      // view(s1);
      for(int j=0;j<6;j++){
        for( auto ps : s1 ){
          set<P> s2;
          dfs(ps.first,ps.second,0,j,v2,s2);
          //cout << "s2 "<< endl;
          //view(s2);
          if( eq(s1, s2) ) {
            //cout << "ok---------" << endl;
            f = true;
          }
        }
      }      
    }
    if( f ) cout << "true" << endl;
    else cout << "false" << endl;
  }
}
accuracy: 1
time_ms: 1520
memory_kb: 3140
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

void pr(mat a){
  int h=a.size(),w=a[0].size();
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<a[i][j];
    }
    cout<<endl;
  }
  cout<<endl;
}


mat cut(mat a){
  
  int h=a.size(),w=a[0].size();
  int ay=1e9,ax=1e9,by=0,bx=0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(a[i][j]!=0){
        ay=min(ay,i);
        ax=min(ax,j);
        by=max(by,i);
        bx=max(bx,j);
      }
  
  mat res=mat(by-ay+1,vec(bx-ax+1));
  for(int y=ay;y<=by;y++)
    for(int x=ax;x<=bx;x++)
      res[y-ay][x-ax]=a[y][x];
  return res;
}


int main(){
  int Tc;cin>>Tc;
  cin.ignore();
  while(Tc--){

    int F;
    string s;
    getline(cin,s);
    
    F=s.size()+2;
    int py=F,px=F;
    mat A(F+F,vec(F+F,0));
    A[py][px]=1;
    for(int i=0;i<(int)s.size();i++){
      if(s[i]=='a')px++;
      if(s[i]=='b')py--;
      if(s[i]=='c')py--,px--;
      if(s[i]=='d')px--;
      if(s[i]=='e')py++;
      if(s[i]=='f')py++,px++;
      A[py][px]=1;
    }
    A=cut(A);

    getline(cin,s);
    bool ans=false;
    for(int T=0;T<6;T++){
      F=s.size()+2;
      mat B(F+F,vec(F+F,0));
      py=F,px=F;
      B[py][px]=1;
              
      for(int i=0;i<(int)s.size();i++){
        if(s[i]=='a')px++,s[i]='b';
        else if(s[i]=='b')py--,s[i]='c';
        else if(s[i]=='c')py--,px--,s[i]='d';
        else if(s[i]=='d')px--,s[i]='e';
        else if(s[i]=='e')py++,s[i]='f';
        else if(s[i]=='f')py++,px++,s[i]='a';
        B[py][px]=1;
      }

      B=cut(B);
      if(A==B)ans=true;
    }
    cout<< (ans?"true":"false") <<endl;
    string tmp;
    getline(cin,tmp);
    assert(tmp=="-");

  }
  return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 1532
final_rank: 13

code_snippet: #include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
char str[1100];
int dx[]={1,1,0,-1,-1,0};
int dy[]={0,1,1,0,-1,-1};

int main(){
	int a;scanf("%d",&a);
	gets(str);
	while(a--){
		gets(str);
		vector<pair<int,int> >v;
		int r=0;int c=0;
		v.push_back(make_pair(0,0));
		for(int i=0;str[i];i++){
			r+=dx[str[i]-'a'];
			c+=dy[str[i]-'a'];
			v.push_back(make_pair(r,c));
		}
		std::sort(v.begin(),v.end());
		gets(str);
		int ret=0;
		for(int i=0;i<6;i++){
			for(int t=0;t<v.size();t++){
				vector<pair<int,int> >w;
				int nr=v[t].first;int nc=v[t].second;
				w.push_back(make_pair(nr,nc));
				for(int j=0;str[j];j++){
					nr+=dx[(str[j]-'a'+i)%6];
					nc+=dy[(str[j]-'a'+i)%6];
					w.push_back(make_pair(nr,nc));
				}
				std::sort(w.begin(),w.end());
				bool ok=true;
				if(v.size()!=w.size())continue;
				for(int j=0;j<v.size();j++){
					if(v[j].first!=w[j].first||v[j].second!=w[j].second)ok=false;
				}
				if(ok){ret=1;break;}
			}
			if(ret)break;
		}
		if(ret)printf("true\n");
		else printf("false\n");
		gets(str);
	}
}
accuracy: 1
time_ms: 150
memory_kb: 1012
final_rank: 12

code_snippet: #include<iostream>
#include<set>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<string>

using namespace std;

int main(){
  int T;
  cin>>T;
  cin.ignore(1);
  while(T--){
    set<set<pair<int,int> > >ss[2];
    for(int i=0;i<2;i++){
      string str;
      getline(cin,str);
      for(int j=0;j<6;j++){
	set<pair<int,int> > s;
	int y=0,x=0;
	for(int k=0;;k++){
	  s.insert(make_pair(x,y)).second;
	  if(k==str.size())break;
	  static int dy[]={-1,-1,0,1,1,0};
	  static int dx[]={0,-1,-1,0,1,1};
	  int idx=(j+str[k]-'a')%6;
	  y+=dy[idx];
	  x+=dx[idx];
	}
	int mx=999,my=999;
	for(auto e:s){
	  mx=min(mx,e.first);
	  my=min(my,e.second);
	}
	set<pair<int,int> > ns;
	for(auto e:s){
	  ns.insert(make_pair(e.first-mx,e.second-my));
	}
	ss[i].insert(ns);
      }
    }  
    cin.ignore(2);
    vector<set<pair<int,int> > > v;
    set_intersection(begin(ss[0]),end(ss[0]),begin(ss[1]),end(ss[1]),back_inserter(v));
    cout<<boolalpha<<(!v.empty())<<endl;
  }
}
accuracy: 1
time_ms: 60
memory_kb: 1276
final_rank: 11

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

using namespace std;

int dx[] = {-1, -1, 0, 1, 1, 0};
int dy[] = {-1, 0, 1, 1, 0, -1};

vector<pair<int, int>> make_set(string &s, int i){
	vector<pair<int, int>> ret;
	auto pos = make_pair(0, 0);

	ret.push_back(pos);
	for (auto c : s){
		pos.first += dx[(c - 'a' + i) % 6];
		pos.second += dy[(c - 'a' + i) % 6];
		ret.push_back(pos);
	}
	sort(ret.begin(), ret.end());
	return ret;
}

bool check(string &s, string &t){
	vector<pair<int, int>> s1 = make_set(s, 0);
	vector<vector<pair<int, int>>> s2(6);
	for (int i = 0; i < 6; ++i) s2[i] = make_set(t, i);

	for (auto p : s1){
		for (int i = 0; i < 6; ++i){
			bool ok = true;
			for (int j = 0; j < s1.size(); ++j){
				int x = s1[j].first - p.first;
				int y = s1[j].second - p.second;
				if (make_pair(x, y) != s2[i][j]) ok = false;
			}

			if (ok) return true;
		}
	}
	return false;
}

int main(){
	int n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; ++i){
		string s, t, u;
		getline(cin, s);
		getline(cin, t);
		getline(cin, u);
		if (s.size() == t.size() && check(s, t)) cout << "true" << '\n';
		else cout << "false" << '\n';
	}

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1208
final_rank: 7

code_snippet: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;

pair<int,int> maja(int x) {
  if (x == 0) return pair<int,int>(0,0);
  int n = static_cast<int>(ceil((-1.0+sqrt(1.0+4.0/3.0*x))/2.0));
  int a = 3*n*(n-1), d = static_cast<int>(ceil((1.0*x-a)/n-1.0));
  int k = x - a - n * d;
  switch (d) {
  case 0: return pair<int,int>(n-k,k);
  case 1: return pair<int,int>(-k,n);
  case 2: return pair<int,int>(-n,n-k);
  case 3: return pair<int,int>(-n+k,-k);
  case 4: return pair<int,int>(k,-n);
  case 5: return pair<int,int>(n,-n+k);
  }
}

int majadist(const pair<int,int> &a, const pair<int,int> &b) {
  int dx = abs(a.first - b.first);
  int dy = abs(a.second - b.second);
  int dz = abs(a.first+a.second-b.first-b.second);
  return min(dx+dy, min(dx+dz, dy+dz));
}

int main(){
  string strN;
  
  int char2num[256];
  char2num['f'] = 1;
  char2num['e'] = 2;
  char2num['d'] = 3;
  char2num['c'] = 4;
  char2num['b'] = 5;
  char2num['a'] = 6;
  int chars[] = {'f','e','d','c','b','a'};

  while(getline(cin,strN)){
    int N = atoi(strN.c_str());
    
    for(int i=0;i<N;i++){
      string routes[2];
      map<pair<int,int>,bool> visited[2][6];

      for(int person=0;person<2;person++){
	getline(cin,routes[person]);

	for(int offset=0;offset< 6;offset++){
	  for(int char_idx=0;char_idx<6;char_idx++){
	    char2num[chars[char_idx]]
	      = (char_idx + offset) % 6 + 1;	  
	  }  
	  pair<int,int> current(0,0);
	  visited[person][offset][current] = true;

	  for(int k=0;k<routes[person].size();k++){
	    current.first 
	      += maja(char2num[routes[person][k]]).first;
	    current.second 
	      += maja(char2num[routes[person][k]]).second;
	    // cout << "x: " << current.first;
	    // cout << " y: " << current.second << endl;
	    visited[person][offset][current] = true;
	  }
	}
      }
	
      string garbage;
      getline(cin,garbage);

      bool res = false;
      for(int src_offset=0;src_offset< 6;src_offset++){
	for(int dst_offset=0;dst_offset< 6;dst_offset++){
	  int offset_x
	    = visited[1][dst_offset].begin()->first.first
	    - visited[0][src_offset].begin()->first.first;
	  int offset_y
	    = visited[1][dst_offset].begin()->first.second
	    - visited[0][src_offset].begin()->first.second;

	  bool isok = true;
	  for(map<pair<int,int>,bool>::iterator it = visited[0][src_offset].begin();
	      it != visited[0][src_offset].end();
	      it++){
	    pair<int,int> moved(it->first.first+offset_x,
				it->first.second+offset_y);
	    if(visited[1][dst_offset].find(moved) == visited[1][dst_offset].end()){
	      isok = false;
	      break;
	    }
	  }
	  res |= isok;
	}
      }
      printf("%s\n",res ? "true" : "false");
    }
  }
}
accuracy: 1
time_ms: 50
memory_kb: 1260
final_rank: 10

code_snippet: #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
 
int dx[] = {0, -1, -1, 0, 1, 1};
int dy[] = {-1, -1, 0, 1, 1, 0};

typedef pair<int, int> P; 

vector<P> move(int d, vector<int> m){
  int x = 0, y = 0;
  int mx = 0, my = 0;
  vector<P> path;
  path.push_back(P(0, 0));
  for(int i = 0 ; i < (int)m.size() ; i++){
    x += dx[ (m[i]+d)%6 ] ,y += dy[ (m[i]+d)%6 ];
    mx = min(mx, x), my = min(my, y);
    path.push_back(P(x, y));
  }
  sort(path.begin(), path.end());
  for(int i = 0 ; i < (int)path.size() ; i++){
    path[i].first -= mx, path[i].second -= my;
  }
  return path;
}

bool solve(vector<int> m1, vector<int> m2){
  vector<P> path1 = move(0, m1);
  
  for(int i = 0 ; i < 6 ; i++){
    vector<P> path2 = move(i, m2);
    if(path1 == path2) return true;
  }
  return false;
}
int main(){
  int n;
  cin >> n;
  cin.ignore();
  string s1, s2, tmp;
  for(int i = 0 ; i < n ; i++){
    getline(cin, s1);
    getline(cin, s2);
    getline(cin, tmp);
 
    vector<int> m1, m2;
    for(int i = 0 ; i < (int)s1.size() ; i++) m1.push_back(s1[i]-'a');
    for(int i = 0 ; i < (int)s2.size() ; i++) m2.push_back(s2[i]-'a');
    
    if(solve(m1, m2)) cout << "true" << endl;
    else cout << "false" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1232
final_rank: 6

code_snippet: #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
 
int dx[] = {0, -1, -1, 0, 1, 1};
int dy[] = {-1, -1, 0, 1, 1, 0};

typedef pair<int, int> P; 

int main(){
  int n;
  cin >> n;
  cin.ignore();
  string s1, s2, tmp;
  for(int i = 0 ; i < n ; i++){
    getline(cin, s1);
    getline(cin, s2);
    getline(cin, tmp);
 
    vector<int> m1, m2;
    for(int i = 0 ; i < (int)s1.size() ; i++) m1.push_back(s1[i]-'a');
    for(int i = 0 ; i < (int)s2.size() ; i++) m2.push_back(s2[i]-'a');
    
    vector<P> path1;
    int x1 = 0, y1 = 0;    
    int mx1 = 0, my1 = 0;
    path1.push_back(P(0, 0));
    for(int i = 0 ; i < (int)m1.size() ; i++){
      x1 += dx[ m1[i] ];
      y1 += dy[ m1[i] ];
      path1.push_back(P(x1, y1));
      mx1 = min(mx1, x1);
      my1 = min(my1, y1);      
    }
    for(int i = 0 ; i < path1.size() ; i++){
      path1[i].first -= mx1;
      path1[i].second -= my1;
    }
    sort(path1.begin(), path1.end());    
    
    bool flag = false;   
    for(int i = 0 ; i < 6 ; i++){
      int x2 = 0, y2 = 0;
      int mx2 = 0, my2 = 0;
      vector<P> path2;
      path2.push_back(P(0, 0));
      for(int j = 0 ; j < (int)m2.size() ; j++){
	x2 += dx[ (m2[j]+i)%6 ];
	y2 += dy[ (m2[j]+i)%6 ];
	path2.push_back(P(x2, y2));
	mx2 = min(mx2, x2);
	my2 = min(my2, y2);
      }
      for(int j = 0 ; j < path2.size() ; j++){
	path2[j].first -= mx2;
	path2[j].second -= my2;
      }
      sort(path2.begin(), path2.end());
      if(path1 == path2){
	flag = true;
	goto END;
      }
    }
  END:;
    if(flag) cout << "true" << endl;
    else cout << "false" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1228
final_rank: 5

code_snippet: #include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

typedef pair<int,int> ii;

const string roulette = "abcdef";
int dx[] = {-1,-1,+0,+1,+1,+0};
int dy[] = {+1,+0,-1,-1,+0,+1};
string line1,line2;
int N;
vector<int> Index[2];

bool check(vector<ii> v1,vector<ii> v2)
{
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  rep(i,N)if(v1[i] != v2[i])return false;
  return true;
}

void compute()
{
  if(line1.size() != line2.size())
    {
      cout << "false" << endl;
      return;
    }
  N = line2.size();
  
  vector<ii> ori;
  int mx,my;
  ori.push_back(ii(0,0));
  
    int x = 0, y = 0;
    mx = my = 0;
    rep(i,N)
      {
	x += dx[line1[i]-'a'];
	y += dy[line1[i]-'a'];
	mx = min(mx,x);
	my = min(my,y);
	ori.push_back(ii(x,y));
      }
  

  rep(i,ori.size())ori[i].first -= mx, ori[i].second -= my;


  rep(j,7)//dir
    {
      vector<ii> cont;
      cont.push_back(ii(0,0));
      x = y = 0;
      mx = x, my = y;
      rep(i,N)
	{
	  x += dx[(line2[i]-'a'+j)%6];
	  y += dy[(line2[i]-'a'+j)%6];
	  mx = min(mx,x);
	  my = min(my,y);
	  cont.push_back(ii(x,y));
	}
      
      rep(i,cont.size())cont[i].first -= mx,cont[i].second -= my;
      
      if(check(ori,cont))
	{
	  cout << "true" << endl;
	  return;
	}
      
    }
      
    
  
  
  cout << "false" << endl;
}


int main()
{
  int n; 
  while(cin >> n)
    {
      cin.ignore();
      string blank;
      while(n--)
	{
	  line1.clear();
	  line2.clear();
	  char c;
	  while((c = getchar()) != '\n')line1 += c;
	  while((c = getchar()) != '\n')line2 += c;
	  cin >> blank;
	  cin.ignore();
	  compute();
	}
    }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1216
final_rank: 4

code_snippet: #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;

const int dx[6] = {1,0,-1,-1,0,1};
const int dy[6] = {0,1,1,0,-1,-1};

set<pair<int,int> > move(const string &s, int diff) {
  int x, y, mx, my;
  set<pair<int,int> > res;
  x = y = mx = my = 0;
  res.insert(make_pair(x,y));
  for(int i = 0; i < s.size(); ++i) {
    int d = (s[i]-'a'+diff)%6;
    x += dx[d];
    y += dy[d];
    res.insert(make_pair(x,y));
    mx = min(mx, x);
    my = min(my, y);
  }
  set<pair<int,int> > res2;
  for(set<pair<int,int> >::iterator it = res.begin();
      it != res.end(); ++it) {
    res2.insert(make_pair(it->first - mx, it->second - my));
  }
  return res2;
}

int main() {
  int Tc;
  cin >> Tc;
  cin.ignore();
  for(int tc = 0; tc < Tc; ++tc) {
    string s, t, dummy;
    getline(cin, s);
    getline(cin, t);
    getline(cin, dummy);
    set<pair<int,int> > ss = move(s, 0);
    bool res = false;
    for(int i = 0; i < 6; ++i) {
      if(move(t, i) == ss) {
	res = true;
	break;
      }
    }
    if(res) cout << "true" << endl;
    else cout << "false" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1212
final_rank: 8

code_snippet: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
 
using namespace std;
 
typedef pair<int, int> P;

set<P> vis[2];
string in[2];
int dy[6] = {1, 0, -1, -1, 0, 1};
int dx[6] = {0, 1, 1, 0, -1, -1};
 
void calc(int p, int d){
  int x = 0, y = 0;
  int mx = 0, my = 0;
  set<P> tmp;
  tmp.insert(P(y, x));
  for(int i=0;i<in[p].size();i++){
    y += dy[(in[p][i]-'a'+d)%6];
    x += dx[(in[p][i]-'a'+d)%6];
    mx = min(mx, x);
    my = min(my, y);
    tmp.insert(P(y, x));
  }
  for(set<P>::iterator ite=tmp.begin();ite!=tmp.end();ite++){
    vis[p].insert(P(ite->first-my, ite->second-mx));
  }
}

bool solve(){
  vis[0].clear();
  calc(0, 0);
  for(int i=0;i<6;i++){
    vis[1].clear();
    calc(1, i);
    if(vis[0] == vis[1]) return true;
  }
  return false;
}
 
int main(){
  int T;
  cin >> T;
  getchar();
  while(T--){
    string s;
    for(int i=0;i<2;i++){
      getline(cin, in[i]);
    }
    getline(cin, s);
    cout << (solve() ? "true" : "false") << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1212
final_rank: 8

code_snippet: #include<cstdio>
#include<cstring>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int dx[6]={1,0,-1,-1,0,1};
const int dy[2][6]={{0,1,0,-1,-1,-1},{1,1,1,0,-1,0}};

bool solve(const char *s,const char *t){
	int m=strlen(s)-1,n=strlen(t)-1;

	if(m!=n) return false;

	pair<int,int> p[128];
	int x=0,y=0;
	rep(i,m+1){
		p[i]=make_pair(x,y);
		if(i<m){
			y+=dy[x&1][s[i]-'a'];
			x+=dx[s[i]-'a'];
		}
	}

	rep(k,m+1) rep(d,6) {
		bool ok=true;
		int x=p[k].first,y=p[k].second;
		rep(i,n+1){
			if(find(p,p+m+1,make_pair(x,y))==p+m+1){ ok=false; break; }
			if(i<n){
				y+=dy[x&1][(t[i]-'a'+d)%6];
				x+=dx[(t[i]-'a'+d)%6];
			}
		}
		if(ok) return true;
	}
	return false;
}

int main(){
	int T; scanf("%d",&T);
	for(getchar();T--;){
		char s[128],t[128];
		fgets(s,128,stdin);
		fgets(t,128,stdin);
		getchar(); getchar();
		puts(solve(s,t)?"true":"false");
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1016
final_rank: 3

code_snippet: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;
void move(int x, int y, int& nx, int& ny, int r){
  int dx[6] = {1, 0, -1, -1, 0, 1};
  int dy[6] = {1, 1, 0, -1, -1, 0};
  nx = x + dx[r];
  ny = y + dy[r];
}

int main(){
  int N;
  cin>>N;
  cin.ignore();
  while(N--){
    string s, t, tmp;
    getline(cin, s);
    getline(cin, t);
    getline(cin, tmp);
    set<P> p_set;
    int x = 0, y = 0;
    p_set.insert(P(x, y));
    REP(i, s.size()){
      move(x, y, x, y, s[i] - 'a');
      //printf("(%d %d) ", x, y);
      p_set.insert(P(x, y));
    }
    bool ans = false;
    REP(d, 6){
      vector<P> p_vect;
      x = 0, y = 0;
      p_vect.push_back(P(x, y));
      REP(i, t.size()){
        move(x, y, x, y, (t[i] - 'a' + d) % 6);
        p_vect.push_back(P(x, y));
      }
      REP(i, p_vect.size()){
        int bx = p_vect[i].first, by = p_vect[i].second;
        set<P> p_set2;
        REP(j, p_vect.size()){
          p_set2.insert(P(p_vect[j].first - bx, p_vect[j].second - by));
        }
        if(p_set == p_set2) ans = true;
      }
    }
    if(ans) cout<<"true"<<endl;
    else cout<<"false"<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 390
memory_kb: 1212
final_rank: 14

code_snippet: #include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++ )
#define MAX 250

bool compute(string str1, string str2){
  bool V1[MAX][MAX], V2[MAX][MAX];
  int ldy1, ldx1, rty1, rtx1;
  int dy[6] = {1, 1, 0, -1, -1, 0};
  int dx[6] = {0, -1, -1, 0, 1, 1};
  if ( str1.size() != str2.size() ) return false;
  int n = (int)str1.size()*2+2;
  rep(y, n) rep(x, n) V1[y][x] = false;

  int py = n/2;
  int px = n/2;
  V1[py][px] = true;
  ldy1 = rty1 = py;
  ldx1 = rtx1 = px;
  rep(i, str1.size()){
    int r = (str1[i]-'a')%6;
    py += dy[r];
    px += dx[r];
    V1[py][px] = true;
    ldy1 = min(ldy1, py);
    ldx1 = min(ldx1, px);
    rty1 = max(rty1, py);
    rtx1 = max(rtx1, px);
  }

  rep(d, 6){
    int ldy2, ldx2, rty2, rtx2;
    py = n/2;
    px = n/2;
    ldy2 = rty2 = py;
    ldx2 = rtx2 = px;
    rep(y, n) rep(x, n) V2[y][x] = false;
    V2[py][px] = true;
    rep(i, str2.size()){
      int r = (str2[i]-'a'+d)%6;
      py += dy[r];
      px += dx[r];
      V2[py][px] = true;
      ldy2 = min(ldy2, py);
      ldx2 = min(ldx2, px);
      rty2 = max(rty2, py);
      rtx2 = max(rtx2, px);
    }
    if ( !(rty1-ldy1 == rty2-ldy2 && rtx1-ldx1 == rtx2-ldx2 ) ) continue;
    int h = rty1-ldy1+1;
    int w = rtx1-ldx1+1;
    bool same = true;
    rep(y, h) rep(x, w){
      if ( V1[y+ldy1][x+ldx1] != V2[y+ldy2][x+ldx2] ) {same = false; break;}
    }
    if ( same ) return true;
  }
  return false;
}

main(){
  int tcase; cin >> tcase;
  string str1, str2, kasu;
  getline(cin, kasu);
  rep(t, tcase) {
    getline(cin, str1);
    getline(cin, str2);
    if (compute(str1, str2) ) cout << "true" << endl;
    else cout << "false" << endl;
    getline(cin, kasu);
  }
}
accuracy: 1
time_ms: 20
memory_kb: 0
final_rank: 1

code_snippet: #include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int dx[] = {1,0,-1,-1, 0,1};
int dy[] = {1,1, 0,-1,-1,0};

bool equals(set<P> a,set<P> b){
  if(a.size() != b.size()) return false;

  set<P>::iterator iterA = a.begin();
  set<P>::iterator iterB = b.begin();
  int diffX = (iterA->first) - (iterB->first);
  int diffY = (iterA->second) - (iterB->second);

  while(iterA != a.end()){
    if((iterA->first) - (iterB->first) != diffX ||
       (iterA->second) - (iterB->second) != diffY){
      return false;
    }
    iterA++;
    iterB++;
  }
  return true;
}

int main(){
  int T;
  string tmp;
  cin>>T;
  getline(cin,tmp);

  while(T--){
    string a,b;
    getline(cin,a);
    getline(cin,b);
    getline(cin,tmp);

    set<P> aset;
    P p(0,0);
    aset.insert(p);

    rep(i,a.length()){
      p.first += dx[a[i] - 'a'];
      p.second += dy[a[i] - 'a'];
      aset.insert(p);
    }

    /*
    for(set<P>::iterator iter=aset.begin();iter!=aset.end();iter++){
      cout<<(iter->first)<<","<<(iter->second)<<endl;
    }
    cout<<"--\n";
    */

    bool flg = false;

    rep(i,6){
      set<P> bset;
      bset.clear();
      p = P(0,0);
      bset.insert(p);
      rep(j,b.length()){
        p.first += dx[((int)b[j] - 'a' + i) % 6];
        p.second += dy[((int)b[j] - 'a' + i) % 6];
        bset.insert(p);
      }
      /*
      if(b.length() > 0 && b[0] == 'b'){
        for(set<P>::iterator iter=bset.begin();iter!=bset.end();iter++){
          cout<<(iter->first)<<","<<(iter->second)<<endl;
        }
        cout<<endl;
      }
      */

      if(equals(aset,bset)){
        flg = true;
        break;
      }
    }

    if(flg){
      cout<<"true\n";
    }
    else{
      cout<<"false\n";
    }
  }
}
accuracy: 1
time_ms: 40
memory_kb: 0
final_rank: 2