QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#259611#5603. Three DicequsolCompile Error//C++141.6kb2023-11-21 06:49:202023-11-21 06:49:20

Judging History

你现在查看的是最新测评结果

  • [2023-11-21 06:49:20]
  • 评测
  • [2023-11-21 06:49:20]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vpll = vector<pll>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;

#define sz(c) ll((c).size())
#define pb(c) push_back(c)
#define all(c) begin(c),end(c)
#define mp make_pair
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll adj[18][18] = {0};
map<char,ll> inds;

ll getInd(char a){
	if(!inds.contains(a)) inds[a] = sz(inds);
	return inds[a];
}

ll solve(ll curr, vl &cols, vl &rem){
	if(curr == 18) return 1;
	
	FOR(i,0,3){
		if(rem[i] == 0) continue;
		ll pos=1;
		FOR(j,0,curr) if(adj[curr][j] && cols[j] == i) pos = 0;
		if(!pos) continue;
		
		cols[curr] = i; rem[i]--;
		if(solve(curr+1, cols, rem)) return 1;
		rem[i]++;
	}
	
	return 0;
}

int main() { cin.sync_with_stdio(0); cin.tie(0);
	ll n; cin >> n;
	
	FOR(i,0,n){
		string a; cin >> a;
		
		FOR(j,1,3) FOR(k,0,j){
			if(getInd(a[j]) >= 18 || getInd(a[k]) >= 18){
				cout << "0\n";
				return 0;
			}
			adj[getInd(a[k])][getInd(a[j])] = 1;
			adj[getInd(a[j])][getInd(a[k])] = 1;
		}
	}
	
	FOR(i,'a','z'+1) if(getInd(i) == 17) break;
	
	vl cols(18);
	vl rem(3,6);
	
	if(!solve(0, cols, rem)) cout << "0\n";
	else{
		vvl die(3);
		for(auto [k,v] : inds){
			die[cols[v]].pb(k);
		}
		
		FOR(i,0,3){
			FOR(j,0,6) cout << (char) die[i][j];
			cout << " ";
		}
		cout << endl;
	}
}

詳細信息

answer.code: In function ‘ll getInd(char)’:
answer.code:28:18: error: ‘class std::map<char, long long int>’ has no member named ‘contains’
   28 |         if(!inds.contains(a)) inds[a] = sz(inds);
      |                  ^~~~~~~~
answer.code: In function ‘int main()’:
answer.code:73:26: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
   73 |                 for(auto [k,v] : inds){
      |                          ^