CSES - Datatähti 2025 alku - Results
Submission details
Task:Kortit II
Sender:maweiyin24562
Submission time:2024-10-28 21:52:20 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp:4:7: error: 'll' does not name a type
    4 | const ll MOD=1000000007;
      |       ^~
input/code.cpp: In function 'void dfsans(int, std::vector<int>, std::vector<int>)':
input/code.cpp:19:30: error: 'MOD' was not declared in this scope
   19 |                         ans%=MOD;
      |                              ^~~

Code

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

const ll MOD=1000000007;

int n,a,b,ans;
vector<int>t;
int cnt;

void dfsans(int u,vector<int>v,vector<int>c){
	if(u==n){
		int sca=0,scb=0;
		for(int i=0;i<n;i++){
			if(c[i]>v[i])sca++;
			else if(v[i]>c[i])scb++;
		}
		if(sca==a&&scb==b){
			ans++;
			ans%=MOD;
//			Sleep(500);
		}
		return;
	}
	for(int i=1;i<=n;i++){
		vector<int>::iterator it=find(v.begin(),v.end(),i);
		if(it==v.end()){
			v.push_back(i);
			dfsans(u+1,v,c);
			v.pop_back();
		}
	}
}

void dfs(int u,vector<int>v){
	if(u==n){
		dfsans(0,t,v);
	}
	for(int i=1;i<=n;i++){
		vector<int>::iterator it=find(v.begin(),v.end(),i);
		if(it==v.end()){
			v.push_back(i);
			dfs(u+1,v);
			v.pop_back();
		}
	}
}

int main(){
	int Q;cin>>Q;
	while(Q--){
		cin>>n>>a>>b;
		dfs(0,t);
		cout<<ans<<endl;
		ans=0;
	}
	
//	cout<<a00<<" "<<a11<<" "<<a12<<" "<<a13<<" "<<a21<<" "<<a22<<" "<<a31<<endl;
}