QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#808138#74. Algorithm TeachingLaVuna47#WA 1ms3736kbC++172.5kb2024-12-10 17:20:392024-12-10 17:20:43

Judging History

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

  • [2024-12-10 17:20:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3736kb
  • [2024-12-10 17:20:39]
  • 提交

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

set<vector<int>> S;

// a is subset of b
bool is_subset(const vector<int>& a, const vector<int>& b)
{
	int j =0;
	FOR(i,0,sz(b))
	{
		if(b[i]==a[j])
			++j;
		if(j==sz(a))
			return true;
	}
	return false;
}

void enumerate(const vector<int>& a, vector<int>& res,int p, int k)
{
	if(k==0)
	{
		for(auto&vec:S)
		{
			if(is_subset(res,vec))
				return;
		}
		auto b=res;
		sort(all(b));
		S.insert(move(b));
		return;
	}
	if(p==-1)return;
	res.pb(a[p]);
	enumerate(a,res,p-1,k-1);
	res.pop_back();
	enumerate(a,res,p-1,k);
}

int solve()
{
	int n;
	if(!(cin>>n))return 1;
	vector<vector<string>> a(n);
	FOR(i,0,n)
	{
		int k;
		cin>>k;
		FOR(j,0,k)
		{
			string s;
			cin>>s;
			a[i].pb(s);
		}
	}
	vector<vector<int>> b(n);
	{
		int ctr=0;
		map<string,int> s;
		int i=0;
		for(auto& vec:a)
		{
			for(auto& word: vec)
			{
				if(s.find(word)==s.end())
				{
					s[word]=ctr++;
				}
				b[i].pb(s[word]);
			}
			++i;
		}
	}
	vector<int> tmp;
	for(auto& vec: b)
	{
		enumerate(vec,tmp,sz(vec)-1,sz(vec)/2);
	}
	cout<<sz(S)<<"\n";
    return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1e9;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

1
3 DFS BFS DIJKSTRA

output:

3

result:

ok single line: '3'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3736kb

input:

100
3 BFS DFS DP
3 BFS DFS DIJKSTRA
3 BFS DFS MAXFLOW
3 BFS DFS GREEDY
3 BFS DFS LCA
3 BFS DP DIJKSTRA
3 BFS DP MAXFLOW
3 BFS DP GREEDY
3 BFS DP LCA
3 BFS DIJKSTRA MAXFLOW
3 BFS DIJKSTRA GREEDY
3 BFS DIJKSTRA LCA
3 BFS MAXFLOW GREEDY
3 BFS MAXFLOW LCA
3 BFS GREEDY LCA
3 DFS DP DIJKSTRA
3 DFS DP MAXF...

output:

63

result:

wrong answer 1st lines differ - expected: '35', found: '63'