제출 #98233

#제출 시각아이디문제언어결과실행 시간메모리
98233dalgerokMate (COCI18_mate)C++17
100 / 100
541 ms14720 KiB
#include<bits/stdc++.h> using namespace std; const int N = 2005, M = 26, MOD = 1e9 + 7; string s; int n, m, dp[N][M][M], sum[N][M]; inline void upd(int &x, int y){ x += y; if(x >= MOD){ x -= MOD; } } int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> s; n = (int)s.size(); for(auto &it : s){ it -= 'a'; } s = '#' + s; for(int i = 1; i <= n; i++){ for(int j = i; j >= 2; j--){ for(int k = 0; k < M; k++){ upd(dp[j][k][s[i]], sum[j - 1][k]); upd(sum[j][s[i]], sum[j - 1][k]); } } upd(sum[1][s[i]], 1); } cin >> m; while(m--){ int len; char x, y; cin >> len >> x >> y; x -= 'a'; y -= 'a'; cout << dp[len][x][y] << "\n"; } }

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

mate.cpp: In function 'int main()':
mate.cpp:32:34: warning: array subscript has type 'char' [-Wchar-subscripts]
                 upd(dp[j][k][s[i]], sum[j - 1][k]);
                                  ^
mate.cpp:33:32: warning: array subscript has type 'char' [-Wchar-subscripts]
                 upd(sum[j][s[i]], sum[j - 1][k]);
                                ^
mate.cpp:36:24: warning: array subscript has type 'char' [-Wchar-subscripts]
         upd(sum[1][s[i]], 1);
                        ^
mate.cpp:45:26: warning: array subscript has type 'char' [-Wchar-subscripts]
         cout << dp[len][x][y] << "\n";
                          ^
mate.cpp:45:29: warning: array subscript has type 'char' [-Wchar-subscripts]
         cout << dp[len][x][y] << "\n";
                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...