| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 845552 | vjudge1 | Trener (COCI20_trener) | C++17 | 1 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 200005
using namespace std;
const int hbase = 127, hmod = 1610612741;
int binpow(int x, int y, const int modulo) {
int ret = 1;
while(y) {
if(y & 1) {
ret *= x;
ret %= modulo;
}
y /= 2;
x *= x;
x %= modulo;
}
return ret;
}
int hashing(string s) {
// cout<<s<<"\n";
int ret = 0;
for(int i = 0; i < s.size(); i++) {
ret += binpow(hbase, i, hmod) * (s[i] - 97);
ret %= hmod;
}
// cout<<ret<<"\n";
return ret;
}
int32_t main(){
fast
int n, k;
cin>>n>>k;
vector<string> ss(n);
map <int, int> dp; // öncekilerin hashleri ile dpleri
for(int i = 0; i < n; i++) {
map <int, int> tdp;
for(int j = 0; j < k; j++) {
cin>>ss[j];
tdp.insert( { hashing(ss[j]), 0ll } );
}
if(!i) { // i 0 ise
for(auto& it:tdp) {
it.second = 1;
}
for(auto it:tdp) {
dp.insert(it);
}
continue;
}
for(auto it:dp) {
}
for(int j = 0; j < k; j++) {
int val = 0;
string temp = ss[j];
temp.erase(temp.begin());
if( dp.count(hashing(temp)) ) val += dp[hashing(temp)];
string temp2 = ss[j];
temp2.pop_back();
if( temp != temp2 and dp.count(hashing(temp2)) ) val += dp[hashing(temp2)];
tdp[hashing(ss[j])] += val;
}
dp.clear();
for(auto it:tdp) {
dp.insert(it);
}
}
int ans = 0;
for(auto it:dp) {
ans += it.second;
}
cout<<ans<<"\n";
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
