제출 #143332

#제출 시각아이디문제언어결과실행 시간메모리
143332nicolaalexandraMate (COCI18_mate)C++14
0 / 100
2064 ms24284 KiB
#include <iostream> #include <vector> #include <set> #include <cstring> #define DIM 2010 #define MOD 1000000007 using namespace std; //ifstream cin ("date.in"); //ofstream cout ("date.out"); int v[DIM],c[DIM][DIM],f[DIM],dp[DIM][30][30]; vector <int> pozx,pozy; set <int> L; char s[DIM],l1,l2; int n,i,j,x,y,q,lg; int main (){ cin>>s+1; n = strlen(s+1); for (i=1;i<=n;i++) v[i] = s[i] - 'a' + 1; c[0][0] = c[1][0] = c[1][1] = 1; for (i=2;i<=n;i++){ c[i][0] = 1; for (j=1;j<=i;j++) c[i][j] = (c[i-1][j] + c[i-1][j-1])%MOD; } for (x=1;x<=26;x++) for (y=1;y<=26;y++){ if (x == 14 && y == 14) x = 14; pozy.clear(), pozx.clear(), L.clear(); memset (f,0,sizeof f); for (i=1;i<=n;i++) if (v[i] == y) pozy.push_back(i); int idx = 0; for (i=1;i<=n;i++){ if (pozy[idx] == i){ for (j=0;j<pozx.size();j++){ L.insert(pozx[j]-1); /// pana unde pot selecta caractere f[pozx[j]-1]++; } if (idx == pozy.size()-1) break; idx++; } if (v[i] == x) pozx.push_back(i); } /// dp[i][x][y] - cate siruri de lungime i care se termina cu xy pot obtine for (i=2;i<=n;i++) for (set<int>:: iterator it=L.begin();it!=L.end();it++){ int lg = *it; dp[i][x][y] = (dp[i][x][y] + c[lg][i-2]*f[lg]%MOD)%MOD; }} cin>>q; for (;q--;){ cin>>lg>>l1>>l2; x = l1-'a'+1, y = l2-'a'+1; cout<<dp[lg][x][y]<<"\n"; } return 0; }

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

mate.cpp: In function 'int main()':
mate.cpp:18:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     cin>>s+1;
          ~^~
mate.cpp:42:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     for (j=0;j<pozx.size();j++){
                              ~^~~~~~~~~~~~
mate.cpp:46:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     if (idx == pozy.size()-1)
                         ~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...