Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gzshawnliang committed Sep 8, 2019
1 parent 1fda982 commit 75baba3
Show file tree
Hide file tree
Showing 21 changed files with 1,533 additions and 0 deletions.
40 changes: 40 additions & 0 deletions myCpps/powerStrings_UVA10298OJ.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <bits/stdc++.h>

using namespace std;


int main()
{
ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
while (true)
{
string s = "."; cin >> s;
if (s == ".") break;

int sizeS = s.size();

int i = 1, j = 0;
vector<int> next(sizeS, 0); next[0] = 0;
while (i <= sizeS - 1)
{
while (j > 0 && s[i] != s[j])
{
if (j > 0) j = next[j - 1];

if (j == -1) break;
}

if (s[i] == s[j]) next[i] = j + 1;

++i;
++j;
}

cout << sizeS / (sizeS - next[sizeS - 1]) << '\n';
}

cout.flush();
return 0;
}

89 changes: 89 additions & 0 deletions myCpps/secretWord_UVA12467.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <bits/stdc++.h>

using namespace std;

ifstream fin("secretWord_UVA12467.in");
ofstream fout("secretWord_UVA12467.out");

int main()
{
int tcc; fin >> tcc;
for (int c = 1; c <= tcc; ++c)
{
string s; fin >> s;
int sizeS = s.size();

int l = 1, r = sizeS;
while (l <= r)
{
int m = (l + r) / 2;

string t = s.substr(0, m); reverse(t.begin(), t.end());
int sizeT = t.size();

int _i = 1, _j = 0;
vector<int> next(sizeT, 0); next[0] = 0;
while (_i <= sizeT - 1)
{
while (_j > 0 && t[_i] != t[_j])
{
if (_j > 0) _j = next[_j - 1];

if (_j == -1) break;
}

if (t[_i] == t[_j]) next[_i] = _j + 1;

++_i;
++_j;
}

bool flag = false;
int i = 0, j = 0;
while (i <= sizeS - 1)
{
if (s[i] != t[j])
{
if (j == 0)
{
++i;
}
else
{
j = next[j - 1];
}
}
else
{
if (j == sizeT - 1)
{
flag = true;
++i;
j = 0;

break;
}
else
{
++i;
++j;
}
}
}

if (flag == true)
{
l = m + 1;
}
else
{
r = m - 1;
}
}

string ans = s.substr(0, l - 1); reverse(ans.begin(), ans.end());
fout << ans << '\n';
}

return 0;
}
151 changes: 151 additions & 0 deletions myCpps/secretWord_UVA12467.in

Large diffs are not rendered by default.

150 changes: 150 additions & 0 deletions myCpps/secretWord_UVA12467.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
mr
uns
dri
dg
veu
pt
ia
hvh
rjn
cof
v
cnb
oys
lr
ip
il
fu
iq
sih
adp
bbb
dps
brv
pxa
fpq
zfv
iqt
txu
pb
ii
lif
hdz
za
gbu
rr
bk
oip
v
sdt
og
pvb
qn
xo
qw
eow
xhx
fwn
ema
ij
uh
vva
kod
wa
de
bo
ehn
dx
tfg
flw
gap
qlex
dm
hzs
wt
wqq
av
fv
odm
wf
mge
loxy
pml
wty
er
jvm
jlj
tww
nyk
zjb
yuz
aeo
xsm
tux
uxn
fyg
aip
pxxp
ijh
qgr
trl
nby
vbk
fat
it
cu
e
kqx
mpp
rn
br
av
jtm
uh
zc
bm
wb
ba
yg
i
lql
ocza
akx
az
pi
rp
fox
tsy
xrg
yf
jw
ci
ij
fql
ty
aa
ty
bdd
rc
gm
im
yoj
szv
yzg
fsw
nzl
tva
vjj
zgl
wv
uo
rs
ssq
kxq
pnw
t
ybl
fmq
i
xqc
qtwnoh
36 changes: 36 additions & 0 deletions myCpps/secretWord_UVA12467Data.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <bits/stdc++.h> //includes everything, supported in CF, usaco, not POJ
#include "MyRandom.h"

using namespace std;

int main()
{
const int FileCount = 10; //note:文件数量
ofstream fout; //note:文件流
random rdNum; //note:随机数


for (int fileId = 1; fileId <= FileCount ; ++fileId)
{
fout.open(to_string(fileId) + ".in");
//***************************
//在此处写入测试数据
//***************************
int T = rdNum.GetRand(150, 150);
fout << T << "\n";
while (T--)
{
int lenT = rdNum.GetRand(1, 30000);
string s="";
for (int i = 0; i <= lenT - 1; ++i)
{
char a = 'a' + rdNum.GetRand(0,25);
s.push_back(a);
}
fout << s << "\n";
}
fout.close();
}

return 0;
}
Loading

0 comments on commit 75baba3

Please sign in to comment.