Submission #120119

#TimeUsernameProblemLanguageResultExecution timeMemory
120119OptxPrimeSajam (COCI18_sajam)C++11
15 / 90
298 ms24312 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include<queue> #include<string.h> #include<map> using namespace std; #define pb push_back #define mp make_pair #define tl TypeLetter #define uc UndoCommands #define gl GetLetter long long n,k; string s[2010]; long long dist[2010][2010][2]; vector<long long>block[2010]; /// ovo bi trebalo da rjesi sve osim K=N long long hamming( int a, int b ) { long long ans=0; for( int i=0;i<block[a].size();i++ ){ // cout << a << " " << b << " " << i << " "<< block[a][i] << " tarik " <<endl; ans+= __builtin_popcount( block[a][i]^block[b][i] ); } return ans; } string kontra( string s ) { string ans=""; ans.resize(n); for( int i=0;i<n;i++ ){ if( s[i]=='x' ) ans[i]='o'; else ans[i]='x'; } return ans; } int main() { cin>>n>>k; //cout << kontra( "xoxx" )<<endl; // // cout<<" pasha " <<endl; for( int i=0;i<2*n;i++ ){ // cout<<i<<" lalala " <<endl; if( i<n ) cin>>s[i]; else s[i]=kontra( s[i-n] ); long long curr=0; for( long long j=0;j<=n;j++ ){ // cout <<j<< " aa " <<endl; if( (j%64LL==0 && j>0) || ( j==n ) ){ // if( i==0 ) cout<< j << " " <<curr << " wtf "<<endl; block[i].pb( curr ); curr=0; if(j==n) break; } if( s[i][j]=='x' ) { curr|=( 1<<( j%64LL ) ); // cout << i << " " << j << " " << ( j%64 ) << " namir " <<endl; } } } //cout << block[1][0] << " eto " <<endl; long long res=100000000; for( int i=0;i<n;i++ ){ long long sum0=0,sum1=0; for( int j=0;j<n;j++ ){ if( i==j ) continue; dist[i][j][0] = hamming( i,j ); // string tmp= kontra( ) ; dist[i][j][0]=min( dist[i][j][0], hamming( i,j+n ) ); dist[i][j][1]= hamming( i+n,j ); dist[i][j][1]=min( dist[i][j][1], hamming( i+n,j+n ) ); // cout<<i << " " << j << " " << dist[i][j][0] << " " << dist[i][j][1] << " tjt " <<endl; sum0+=dist[i][j][0]; sum1+=dist[i][j][1]; } res=min( res,sum0 ); res=min(res,sum1); } //cout<<res<<endl; if( res<=k ) cout<<"DA"<<endl; else cout<<"NE"<<endl; return 0; } /* 5 1 2 1 2 2 */

Compilation message (stderr)

sajam.cpp: In function 'long long int hamming(int, int)':
sajam.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for( int i=0;i<block[a].size();i++ ){
                    ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...