제출 #143948

#제출 시각아이디문제언어결과실행 시간메모리
143948Linca_RobertMate (COCI18_mate)C++14
100 / 100
429 ms26412 KiB
#include<bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int N, Q, Dp[2005][30][30], Comb[2005][2005], Cnt[2005][30]; int Sol[30][30]; char s[2205], aux[5]; int main(){ scanf( "%s", s + 1 ); N = strlen( s + 1 ); Comb[0][0] = 1; for( int i = 1; i <= N; i++ ){ Comb[i][0] = Comb[i][i]= 1; for( int j = 1; j < i; j++ ){ Comb[i][j] = Comb[i - 1][j] + Comb[i - 1][j - 1]; if( Comb[i][j] >= MOD ) Comb[i][j] -= MOD; } } for( int i = N; i >= 1; i-- ){ for( int sg = 0; sg <= 'z' - 'a'; sg++ ) Cnt[i][sg] += Cnt[i + 1][sg]; if( i > 1 ) Cnt[i - 1][ s[i] - 'a' ]++; } for( int L = 0; L <= N - 2; L++ ){ for( int i = L + 1; i <= N; i++ ){ for( int j = 0; j <= 'z' - 'a'; j++ ){ Dp[L + 2][ s[i] - 'a' ][j] += ( 1LL * Comb[i - 1][L] * Cnt[i][j] % MOD ); if( Dp[L + 2][ s[i] - 'a' ][j] >= MOD ) Dp[L + 2][ s[i] - 'a' ][j] -= MOD; } } } scanf( "%d", &Q ); for( ; Q; Q-- ){ int x; scanf( "%d%s", &x, aux ); printf( "%d\n", Dp[x][ aux[0] - 'a' ][ aux[1] - 'a' ] ); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

mate.cpp: In function 'int main()':
mate.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf( "%s", s + 1 );
     ~~~~~^~~~~~~~~~~~~~~
mate.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf( "%d", &Q );
     ~~~~~^~~~~~~~~~~~
mate.cpp:43:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf( "%d%s", &x, aux );
                ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...