CSES - Datatähti 2025 alku - Results
Submission details
Task:Niitty
Sender:a256
Submission time:2024-10-30 17:07:37 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

In file included from /usr/include/features.h:486,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586,
                 from /usr/include/c++/11/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from input/code.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h: In function 'int main()':
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:57:1: error: inlining failed in call to 'always_inline' 'void* memset(void*, int, size_t) noexcept': target specific option mismatch
   57 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
input/code.cpp:25:23: note: called from here
   25 |                 memset(z,0,sizeof z);
      |                 ~~~~~~^~~~~~~~~~~~~~

Code

#include<bits/stdc++.h>
#pragma GCC target("arch=skylake")
#pragma GCC optimize("O3,unroll-all-loops")
using namespace std;
#define ll long long
#define CCC(i) h[i]=(h[i]+1)*!(k&(1<<i));

#define N 500
int n,C,t[N][N],z[N];
ll R,r;

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		for(int j=0;j<n;++j){
			int c=1<<(s[j]-'A');
			t[i][j]=c;
			C|=c;
		}
	}
	for(int l=0;l<n;++l){
		memset(z,0,sizeof z);
		for(int r=l;r<n;++r){
			for(int i=0;i<n;++i) z[i]|=t[r][i];
			int h[26]={0};
			for(int i=0;i<n;++i){
				int k=z[i];
				CCC(0);
				CCC(1);
				CCC(2);
				CCC(3);
				CCC(4);
				CCC(5);
				CCC(6);
				CCC(7);
				CCC(8);
				CCC(9);
				CCC(10);
				CCC(11);
				CCC(12);
				CCC(13);
				CCC(14);
				CCC(15);
				CCC(16);
				CCC(17);
				CCC(18);
				CCC(19);
				CCC(20);
				CCC(21);
				CCC(22);
				CCC(23);
				CCC(24);
				CCC(25);
				//int m=max(max(max(max(max(h[0],h[1]),max(h[2],h[3])),max(max(h[4],h[5]),max(h[6],h[7]))),
				//max(max(max(h[8],h[9]),max(h[10],h[11])),max(max(h[12],h[13]),max(h[14],h[15])))),
				//max(max(max(max(h[16],h[17]),max(h[18],h[19])),max(max(h[20],h[21]),max(h[22],h[23]))),
				//max(h[24],h[25])));
				int m=0;
				for(int c=0;c<26;++c){
					if(!(C&(1<<c))) continue;
					m=max(m,h[c]);
				}

				R+=m;
			}
		}
	}

	r=n*(n+1)/2;
	r*=r;
	r-=R;
	cout<<r<<'\n';
}