# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223208 | 2020-04-15T05:15:37 Z | jamielim | Trener (COCI20_trener) | C++14 | 12 ms | 7168 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD=1000000007; string str[20][1505]; pair<string,int> str2[20][3005]; int main(){ int n,k; scanf("%d%d",&n,&k); char temp[55]; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ scanf("%s",temp); str[i][j]=temp; } sort(str[i],str[i]+k); if(i!=0){ for(int j=0;j<k;j++){ for(int l=0;l<i;l++){ str2[i][j].first+=str[i][j][l]; str2[i][j+k].first+=str[i][j][l+1]; str2[i][j].second=str2[i][j+k].second=j; } } sort(str2[i],str2[i]+2*k); //for(int j=0;j<2*k;j++)printf("%s ",str2[i][j].first.c_str()); //printf("\n"); } } ll dp[n][k]; memset(dp,0,sizeof(dp)); for(int i=0;i<k;i++)dp[n-1][i]=1; for(int i=n-2;i>=0;i--){ int ptr=0; bitset<1505> done; for(int j=0;j<k;j++){ done.reset(); if(j!=0&&str[i][j]==str[i][j-1]){ dp[i][j]=dp[i][j-1];continue; } while(ptr<2*k){ if(str[i][j]==str2[i+1][ptr].first&&done[str2[i+1][ptr].second]==0){ done[str2[i+1][ptr].second]=1; dp[i][j]+=dp[i+1][str2[i+1][ptr].second]; dp[i][j]%=MOD; }else if(str[i][j]<str2[i+1][ptr].first)break; ptr++; } //printf("%lld ",dp[i][j]); } //printf("\n"); } ll ans=0; for(int i=0;i<k;i++){ans+=dp[0][i];ans%=MOD;} printf("%lld",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3584 KB | Output is correct |
2 | Correct | 6 ms | 3584 KB | Output is correct |
3 | Correct | 6 ms | 3584 KB | Output is correct |
4 | Correct | 6 ms | 3584 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 7168 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3584 KB | Output is correct |
2 | Correct | 6 ms | 3584 KB | Output is correct |
3 | Correct | 6 ms | 3584 KB | Output is correct |
4 | Correct | 6 ms | 3584 KB | Output is correct |
5 | Runtime error | 12 ms | 7168 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Halted | 0 ms | 0 KB | - |