Submission #2214993


Source Code Expand

#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
#define mat vector<vector<ll> >

const int M=101;

int n,k;

int num[110];
string s[110];
string ans[20];
vector<int> t[50];//i番目の文字の数のj桁目
int pt[50];
bool used[20];
bool ok;
string res[50];

void dfs(int p,ll z,int sum){
	//cout<<p<<" "<<z<<endl;
	if(ok)return;

if(p>=k){
	//cout<<p<<" "<<z<<endl;
	bool is=1;
	int pos=0;
	rep(i,k)used[i]=0;
	ll zz=z;
	while(zz){
		pt[pos++]=zz%10;
		zz/=10;
	}
	
	reverse(pt,pt+pos);
	rep(i,n){
		string tmp="";//全体
		string tan="";//数字と対応する文字
		int now=0;
		rep(j,t[i].size()){
			tan="";
			rep(l,pt[t[i][j]])tan.push_back(s[i][now++]);
			if(now>s[i].size()){is=0;continue;}
			if(used[t[i][j]]){if(tan!=res[t[i][j]])is=0;}
			else{
				//cout<<t[i][j]<<" *"<<tan<<" ";
			 res[t[i][j]]=tan;
				used[t[i][j]]=1;
			}
			//cout<<tan<<" ";
		}
		//cout<<endl;
		if(now!=s[i].size())is=0;
	}
	if(is)ok=1;
	if(is){
		//cout<<z<<":";
		rep(i,k)cout<<res[i]<<endl;
	}
	return;
}

for(ll i=1;i<=3;i++){
	dfs(p+1,z*10+i,sum+i);
}

}
	

int main(){
	cin>>k>>n;
	rep(i,n){
		cin>>num[i]>>s[i];
		int z=num[i],pos=0;
		while(z){
			t[i].push_back(z%10-1);
			z/=10;
		}
		reverse(t[i].begin(),t[i].end());
	}
	dfs(0,0,0);	

	return 0;
}

Submission Info

Submission Time
Task D - 語呂合わせ
User pappagukun
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1664 Byte
Status CE

Compile Error

./Main.cpp:17:12: error: ‘__int64’ has not been declared
 #define ll __int64
            ^
./Main.cpp:34:16: note: in expansion of macro ‘ll’
 void dfs(int p,ll z,int sum){
                ^
./Main.cpp: In function ‘void dfs(int, int, int)’:
./Main.cpp:17:12: error: ‘__int64’ was not declared in this scope
 #define ll __int64
            ^
./Main.cpp:43:2: note: in expansion of macro ‘ll’
  ll zz=z;
  ^
./Main.cpp:44:8: error: ‘zz’ was not declared in this scope
  while(zz){
        ^
./Main.cpp:17:12: error: ‘__int64’ was not declared in this scope
 #define ll __int64
            ^
./Main.cpp:77:5: note: in expansion of macro ‘ll’
 for(ll i=1;i<=3;i++){
     ^
./Main.cpp:77:12: error: ‘i’ was not declared in this scope
 for(ll i=1;i<=3;i++){
            ^