Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
npofsi committed Oct 12, 2021
1 parent ab32b84 commit d23a974
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 0 deletions.
11 changes: 11 additions & 0 deletions oj/hdu/hdu_contest_1038_ccpc_online/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0.0)
project(main VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(main main.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
108 changes: 108 additions & 0 deletions oj/hdu/hdu_contest_1038_ccpc_online/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;

typedef long long ll;
ll arr[100010];
ll mta[100010];
ll smt[100010][11];
ll M = 998244353;
inline int pos(char c)
{
return c - 'a';
}
int main(int, char **)
{
int n = 0;
cin >> n;
char *spr = "nunhehheh";
for (int i = 0; i < n; i++)
{
char str[100010];
memset(mta, 0, 100002);
ll sumx = 0;
scanf("%s", str);

int len = strlen(str);
if (len < 10)
{
cout << 0 << endl;
continue;
}
if (spr[0] == str[0])
{
smt[0][0] = 1ll;
}
else
{
smt[0][0] = 0ll;
}

for (int i = 1; i < len; i++)
{
if (str[i] == spr[0])
{
smt[i][0] = smt[i - 1][0] + 1ll;
}
else
{
smt[i][0] = smt[i - 1][0];
}
}

for (int i = 1; i < 9; i++)
{
if (spr[i] == str[0])
{
smt[0][i] = 0ll;
}
else
{
smt[0][i] = 0ll;
}
}

for (int i = 1; i < 9; i++)
{
for (int j = 1; j < len; j++)
{
if (spr[i] == str[j])
{
smt[j][i] = (smt[j - 1][i] + smt[j - 1][i - 1]) % M;
if (i == 8)
{
mta[j] = smt[j - 1][i - 1];
}
}
else
{
smt[j][i] = smt[j - 1][i];
}
//cout << smt[j][i] << " ";
}
//cout << endl;
}

if (str[len - 1] == 'a')
arr[len - 1] = 1ll;
else
arr[len - 1] = 0ll;

for (int j = len - 2; j >= 0; j--)
{
if (str[j] == 'a')
{
arr[j] = (2ll * arr[j + 1] + 1ll) % M;
}
else
{
arr[j] = arr[j + 1];
sumx = (sumx + (arr[j] * mta[j]) % M) % M;
}
}
cout << sumx << endl;
}
}
11 changes: 11 additions & 0 deletions oj/vjudge/460621/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0.0)
project(main VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(main main.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
63 changes: 63 additions & 0 deletions oj/vjudge/460621/Cx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int manx = 8e5 + 10;
const ull base = 31;

char s[manx];
int len;
ull hhash[manx], mul[manx];
void init()
{
mul[0] = 1, hhash[0] = 0;
for (int i = 1; i <= len; i++)
mul[i] = mul[i - 1] * base;
for (int i = 1; i <= len; i++)
hhash[i] = hhash[i - 1] * base + s[i];
}
ull getHash(int l, int r)
{
return hhash[r] - hhash[l - 1] * mul[r - l + 1];
}
int main()
{
scanf("%s", s + 1);
len = strlen(s + 1);
init();
for (int i = 1; i <= len / 3; i++)
{
ull c[] = {0, getHash(1, i), 0, 0, 0}, now = 1;
int posb;
for (int j = 1; j <= len - i + 1; j += i)
{
ull temp = getHash(j, j + i - 1);
if (temp != c[now])
{
c[++now] = temp;
if (now == 2)
posb = j;
}
if (now > 3)
break;
}
if (now == 3 && c[1] == c[3])
{
int l = len % i;
if (getHash(1, l) == getHash(len - l + 1, len))
{
for (int j = 1; j <= i; j++)
putchar(s[j]);
putchar(' ');
for (int j = posb; j <= posb + i - 1; j++)
putchar(s[j]);
putchar('\n');
}
return 0;
}
}
return 0;
}
71 changes: 71 additions & 0 deletions oj/vjudge/460621/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int N = 8e5 + 5;
const ull base = 31;

char s[N];

int len;
ull shash[N], mul[N];

void initHash()
{
mul[0] = 1;
shash[0] = 0;
for (int i = 1; i <= len; i++)
{
mul[i] = mul[i - 1] * base;
}
for (int i = 1; i <= len; i++)
{
shash[i] = shash[i - 1] * base + s[i];
}
}
ull modHash(int l, int r)
{
return shash[r] - shash[l - 1] * mul[r - l + 1];
}
int main(int, char **)
{
scanf("%s", s + 1);
//cout << s + 1 << endl;
len = strlen(s + 1);
initHash();
for (int i = 1; i <= len / 3; i++)
{
ull c[] = {0, 0, 0, 0, 0};
c[1] = modHash(1, i);
ull now = 1;
int pos;
for (int j = 1; j <= len - i + 1; j += i)
{
ull m = modHash(j, j + i - 1);
if (m != c[now])
{
c[++now] = m;
if (now == 2)
pos = j;
}
if (now > 3)
break;
}
if (now == 3 && c[1] == c[3])
{
int l = len % i;
if (modHash(1, l) == modHash(len - l + 1, len))
{
//cout << s + 1 << endl;
string str = string(s + 1);
cout << str.substr(0, i) << " " << str.substr(pos - 1, i) << endl;
}
return 0;
}
}
return 0;
}
11 changes: 11 additions & 0 deletions oj/vjudge/460967/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0.0)
project(main VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(main D.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
32 changes: 32 additions & 0 deletions oj/vjudge/460967/D.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>
#include <string.h>
#include <string>
using namespace std;

string suffixsx[] = {"a", "i", "y", "l", "n", "ne", "o", "r", "t", "u", "v", "w"};
string suffixsy[] = {"as", "ios", "ios", "les", "anes", "anes", "os", "res", "tas", "us", "ves", "was"};

int main(int, char **)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
string str;
cin >> str;
int flag = 0;
int len = str.size();
for (int i = 0; i < 12; i++)
{
int lp = suffixsx[i].size();
if (strcmp(str.substr(len - lp).c_str(), suffixsx[i].c_str()) == 0)
{
cout << str.substr(0, len - lp) << suffixsy[i] << endl;
flag = 1;
break;
}
}
if (flag == 0)
cout << str << "us" << endl;
}
}

0 comments on commit d23a974

Please sign in to comment.