QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#260001#1965. TriohuziCompile Error//C++141.7kb2023-11-21 17:41:182023-11-21 17:41:20

Judging History

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

  • [2023-11-21 17:41:20]
  • 评测
  • [2023-11-21 17:41:18]
  • 提交

answer

#include "iostream"
using namespace std;
int cnt[11][11][11][11];
inline sl(int *a){    //与某一个数字相等的位和不相等的位的个数都列出来 
	cnt[a[0]][a[1]][a[2]][a[3]] ++ ; //1111 
	cnt[a[0]][a[1]][a[2]][0] ++;      //1110
	cnt[a[0]][a[1]][0][a[3]]++ ; //  1101
	cnt[a[0]][a[1]][0][0] ++; //    1100
	cnt[a[0]][0][a[2]][a[3]] ++ ;  //1011
	cnt[a[0]][0][a[2]][0] ++;  //1010
	cnt[a[0]][0][0][a[3]] ++ ; //1001
	cnt[a[0]][0][0][0] ++;      //1000
	cnt[0][a[1]][a[2]][a[3]] ++ ;  //0111
	cnt[0][a[1]][a[2]][0] ++;      //0110
	cnt[0][a[1]][0][a[3]] ++ ;    //0101
	cnt[0][a[1]][0][0] ++; //  0100
	cnt[0][0][a[2]][a[3]] ++ ;// 0011
	cnt[0][0][a[2]][0] ++;  //0010
	cnt[0][0][0][a[3]] ++ ;  //0001
	cnt[0][0][0][0] ++;   //0000
}
long long find(int now, int *a, int *b, int *c){
	long long sum = 0;
	if(now == 4) sum += cnt[c[0]][c[1]][c[2]][c[3]];
	else if(a[now] == b[now]){
		c[now] = a[now];
		sum += find(now +1, a, b, c);
		
	}
	else {
		c[now] = 0;
		sum += find(now + 1, a, b,c); //先加上所有和当前位不相等的数的数量 
		c[now] = a[now];     //减去当前位和a的当前位相等的数的数量 
		sum -= find(now + 1, a, b, c);
		c[now] = b[now];    //减去当前位和b的当前位相等的数的数量 
		sum -= find(now + 1, a, b, c);
		
	}
	return sum; 
} 
int main(){
	ios::sync_with_stdio(false),cin.tie(0), cout.tie(0);
	int t;
	cin>>t;
	long long ans = 0;
	int num[3000][7];
	for(int i = 0; i < t; i++){
		 string s;
		 cin>>s;
		 for(int j = 0; j < 4; j ++){
		 	num[i][j] = s[j] - '0';
		 }
		 sl(num[i]);
	}
	int ann[5];
	for(int i = 0; i < t; i ++){
		for(int j = i + 1; j < t; j ++){
			ans += find(0, num[i], num[j], ann);
		}
	}
	cout<<ans/3<<endl;
	return 0;
}

Details

answer.code:4:8: error: ISO C++ forbids declaration of ‘sl’ with no type [-fpermissive]
    4 | inline sl(int *a){    //与某一个数字相等的位和不相等的位的个数都列出来
      |        ^~
answer.code: In function ‘int sl(int*)’:
answer.code:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^