Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gzshawnliang committed Mar 7, 2019
1 parent a9614d8 commit b2c19f0
Show file tree
Hide file tree
Showing 77 changed files with 41,613 additions and 47 deletions.
4,184 changes: 4,184 additions & 0 deletions HDU/HDU_1754/1.in

Large diffs are not rendered by default.

2,026 changes: 2,026 additions & 0 deletions HDU/HDU_1754/1.out

Large diffs are not rendered by default.

2,208 changes: 2,208 additions & 0 deletions HDU/HDU_1754/10.in

Large diffs are not rendered by default.

1,089 changes: 1,089 additions & 0 deletions HDU/HDU_1754/10.out

Large diffs are not rendered by default.

3,143 changes: 3,143 additions & 0 deletions HDU/HDU_1754/2.in

Large diffs are not rendered by default.

1,529 changes: 1,529 additions & 0 deletions HDU/HDU_1754/2.out

Large diffs are not rendered by default.

3,450 changes: 3,450 additions & 0 deletions HDU/HDU_1754/3.in

Large diffs are not rendered by default.

1,680 changes: 1,680 additions & 0 deletions HDU/HDU_1754/3.out

Large diffs are not rendered by default.

1,245 changes: 1,245 additions & 0 deletions HDU/HDU_1754/4.in

Large diffs are not rendered by default.

628 changes: 628 additions & 0 deletions HDU/HDU_1754/4.out

Large diffs are not rendered by default.

3,377 changes: 3,377 additions & 0 deletions HDU/HDU_1754/5.in

Large diffs are not rendered by default.

1,714 changes: 1,714 additions & 0 deletions HDU/HDU_1754/5.out

Large diffs are not rendered by default.

1,105 changes: 1,105 additions & 0 deletions HDU/HDU_1754/6.in

Large diffs are not rendered by default.

563 changes: 563 additions & 0 deletions HDU/HDU_1754/6.out

Large diffs are not rendered by default.

994 changes: 994 additions & 0 deletions HDU/HDU_1754/7.in

Large diffs are not rendered by default.

530 changes: 530 additions & 0 deletions HDU/HDU_1754/7.out

Large diffs are not rendered by default.

3,826 changes: 3,826 additions & 0 deletions HDU/HDU_1754/8.in

Large diffs are not rendered by default.

1,878 changes: 1,878 additions & 0 deletions HDU/HDU_1754/8.out

Large diffs are not rendered by default.

3,496 changes: 3,496 additions & 0 deletions HDU/HDU_1754/9.in

Large diffs are not rendered by default.

1,755 changes: 1,755 additions & 0 deletions HDU/HDU_1754/9.out

Large diffs are not rendered by default.

128 changes: 128 additions & 0 deletions HDU/HDU_1754/IHateIt_1754.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#include <bits/stdc++.h>

using namespace std;

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

class SegTree
{
private:
int sizeA; //原数组的大小
vector<int> a; //原数组
vector<int> segTree; //线段树的数组

void build(int l, int r, int i)
{
if (i > sizeA * 4 - 1)
return;

if (l == r)
{
segTree[i] = a[l];
return;
}

int m = (l + r) / 2;

build(l, m, i * 2);
build(m + 1, r, i * 2 + 1);

segTree[i] = max(segTree[i * 2], segTree[i * 2 + 1]);
}

int query(int l, int r, int i, int nowLeft, int nowRight)
{
if (nowRight < l || r < nowLeft)
{
return INT_MIN;
}
if (nowLeft >= l && nowRight <= r)
{
return segTree[i];
}

int m = (nowLeft + nowRight) / 2;

return max(query(l, r, i * 2, nowLeft, m), query(l, r, i * 2 + 1, m + 1, nowRight));
}

void update(int pos, int _new, int i, int nowLeft, int nowRight)
{
if (pos < nowLeft || pos > nowRight)
{
return;
}

if (nowLeft == nowRight)
{
a[pos] = _new;
segTree[i] = _new;
return;
}

int m = (nowLeft + nowRight) / 2;
update(pos, _new, i * 2, nowLeft, m);
update(pos, _new, i * 2 + 1, m + 1, nowRight);
//segTree[i] = max(update(pos, _new, i * 2, nowLeft, m), update(pos, _new, i * 2 + 1, m + 1, nowRight));
segTree[i] = max(segTree[i*2],segTree[i*2+1]);
}

public:
SegTree(const vector<int> & p_Sour)
{
a = p_Sour;
sizeA = a.size();
segTree.assign(sizeA * 4, INT_MIN);

build(0, sizeA-1, 1);
}

int query(int l, int r)
{
return query(l, r, 1, 0, sizeA-1);
}

void update(int index, int newVal)
{
update(index, newVal, 1, 0, sizeA-1);
}
};

int main()
{
while (true)
{
int n = 0, m = 0;
fin >> n >> m;
if (n + m == 0)
break;

vector<int> a(n);

for (int i = 0; i <= n-1; ++i)
{
fin >> a[i];
}

SegTree tree(a);

for (int c = 1; c <= m; ++c)
{
char ch;
int _i, _j;
fin >> ch >> _i >> _j;

if (ch == 'Q')
{
fout << tree.query(_i-1, _j-1) << '\n';
}
else
{
tree.update(_i-1, _j);
}
}
}

return 0;
}
10 changes: 10 additions & 0 deletions HDU/HDU_1754/IHateIt_1754.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
5 7
17 29 27 19 25
U 3 5
Q 1 2
Q 2 4
U 3 5
U 3 5
Q 1 3
Q 2 3

4 changes: 4 additions & 0 deletions HDU/HDU_1754/IHateIt_1754.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
29
29
29
29
131 changes: 131 additions & 0 deletions HDU/HDU_1754/IHateIt_1754OJ.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include <bits/stdc++.h>

using namespace std;

// ifstream cin("IHateIt_1754.in");
// ofstream cout("IHateIt_1754.out");

class SegTree
{
private:
int sizeA; //原数组的大小
vector<int> a; //原数组
vector<int> segTree; //线段树的数组

void build(int l, int r, int i)
{
if (i > sizeA * 4 - 1)
return;

if (l == r)
{
segTree[i] = a[l];
return;
}

int m = (l + r) / 2;

build(l, m, i * 2);
build(m + 1, r, i * 2 + 1);

segTree[i] = max(segTree[i * 2], segTree[i * 2 + 1]);
}

int query(int l, int r, int i, int nowLeft, int nowRight)
{
if (nowRight < l || r < nowLeft)
{
return INT_MIN;
}
if (nowLeft >= l && nowRight <= r)
{
return segTree[i];
}

int m = (nowLeft + nowRight) / 2;

return max(query(l, r, i * 2, nowLeft, m), query(l, r, i * 2 + 1, m + 1, nowRight));
}

void update(int pos, int _new, int i, int nowLeft, int nowRight)
{
if (pos < nowLeft || pos > nowRight)
{
return;
}

if (nowLeft == nowRight)
{
a[pos] = _new;
segTree[i] = _new;
return;
}

int m = (nowLeft + nowRight) / 2;
update(pos, _new, i * 2, nowLeft, m);
update(pos, _new, i * 2 + 1, m + 1, nowRight);
//segTree[i] = max(update(pos, _new, i * 2, nowLeft, m), update(pos, _new, i * 2 + 1, m + 1, nowRight));
segTree[i] = max(segTree[i*2],segTree[i*2+1]);
}

public:
SegTree(const vector<int> & p_Sour)
{
a = p_Sour;
sizeA = a.size();
segTree.assign(sizeA * 4, INT_MIN);

build(0, sizeA-1, 1);
}

int query(int l, int r)
{
return query(l, r, 1, 0, sizeA-1);
}

void update(int index, int newVal)
{
update(index, newVal, 1, 0, sizeA-1);
}
};

int main()
{
ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
while (true)
{
int n = 0, m = 0;
cin >> n >> m;
if (n + m == 0)
break;

vector<int> a(n);

for (int i = 0; i <= n-1; ++i)
{
cin >> a[i];
}

SegTree tree(a);

for (int c = 1; c <= m; ++c)
{
char ch;
int _i, _j;
cin >> ch >> _i >> _j;

if (ch == 'Q')
{
cout << tree.query(_i-1, _j-1) << '\n';
}
else
{
tree.update(_i-1, _j);
}
}
}

cout.flush();
return 0;
}
4 changes: 4 additions & 0 deletions HDU/HDU_1754_AC/1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
4 2
8 3 10 19
Q 1 3
Q 1 2
2 changes: 2 additions & 0 deletions HDU/HDU_1754_AC/1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
10
8
5 changes: 5 additions & 0 deletions HDU/HDU_1754_AC/10.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
9 3
30 2 21 5 10 25 19 21 27
U 7 8
U 1 3
Q 2 8
1 change: 1 addition & 0 deletions HDU/HDU_1754_AC/10.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25
6 changes: 6 additions & 0 deletions HDU/HDU_1754_AC/2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
17 4
26 23 7 26 6 9 4 13 19 27 28 4 26 22 12 10 2
Q 2 6
Q 10 17
Q 13 17
Q 1 7
4 changes: 4 additions & 0 deletions HDU/HDU_1754_AC/2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
26
28
26
26
8 changes: 8 additions & 0 deletions HDU/HDU_1754_AC/3.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
20 6
8 1 12 8 26 2 5 14 13 29 9 26 26 30 26 7 13 29 5 27
Q 6 9
U 4 5
Q 1 12
Q 2 5
U 5 10
Q 8 19
4 changes: 4 additions & 0 deletions HDU/HDU_1754_AC/3.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
14
29
26
30
4 changes: 4 additions & 0 deletions HDU/HDU_1754_AC/4.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
11 2
19 12 9 18 25 30 6 21 25 22 16
Q 1 7
Q 4 11
2 changes: 2 additions & 0 deletions HDU/HDU_1754_AC/4.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
30
30
10 changes: 10 additions & 0 deletions HDU/HDU_1754_AC/5.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
11 8
19 16 18 22 1 10 4 1 15 1 23
Q 6 11
Q 2 7
Q 3 9
U 1 11
U 1 7
Q 1 11
U 4 9
Q 7 11
5 changes: 5 additions & 0 deletions HDU/HDU_1754_AC/5.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
23
22
22
23
23
8 changes: 8 additions & 0 deletions HDU/HDU_1754_AC/6.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
3 6
5 25 23
Q 2 3
Q 1 3
Q 1 2
Q 1 3
U 1 3
Q 1 2
5 changes: 5 additions & 0 deletions HDU/HDU_1754_AC/6.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
25
25
25
25
25
12 changes: 12 additions & 0 deletions HDU/HDU_1754_AC/7.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
4 10
14 16 12 25
U 2 4
U 3 4
U 3 4
U 2 4
U 1 4
Q 1 3
U 1 2
U 1 4
Q 2 4
Q 2 3
3 changes: 3 additions & 0 deletions HDU/HDU_1754_AC/7.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
4
25
4
7 changes: 7 additions & 0 deletions HDU/HDU_1754_AC/8.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
4 5
19 3 26 10
U 1 2
U 2 4
Q 1 2
Q 2 3
Q 1 3
3 changes: 3 additions & 0 deletions HDU/HDU_1754_AC/8.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
4
26
26
5 changes: 5 additions & 0 deletions HDU/HDU_1754_AC/9.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
19 3
20 17 15 11 23 8 19 15 3 17 11 10 4 28 12 7 17 25 26
Q 1 11
Q 5 8
Q 10 11
3 changes: 3 additions & 0 deletions HDU/HDU_1754_AC/9.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
23
23
17
Loading

0 comments on commit b2c19f0

Please sign in to comment.