Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
using namespace std; typedef long long ll; const int INF = (1 << 30); const ll inf = (1LL << 60LL); const int maxn = 1e5 + 5; const ll MOD = (ll)(1e9 + 7); int n; string s; map
cnt; int main(int argc, const char * argv[]) { ios_base::sync_with_stdio(false); cin >> n >> s; vector
pos; int k = 0, mnn; for(int i = 0; i < n; i ++){ if(cnt.find(s[i]) == cnt.end()){ cnt[s[i]] = k; ++k; } pos.push_back(cnt[s[i]]); } map
, int> mapa; vector
at(k); ll ret = 0; for(int i = 0; i < (int)pos.size(); i ++){ mapa[at] ++; at[pos[i]] ++; mnn = INF; for(int j = 0; j < (int)at.size(); j ++){ mnn = min(mnn, at[j]); } for(int j = 0; j < (int)at.size(); j ++){ at[j] -= mnn; } ret += mapa[at]; ret %= MOD; } cout << ret << endl; return 0; } /* 10 1 10 1 4 2 8 7 3 3 10 2 10 5 1 2 4 2 3 5 4 */ /* 10 1 10 1 4 2 8 7 3 3 10 2 10 5 1 2 4 2 3 5 4 */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)