-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
aoapc-book
committed
Jul 13, 2014
1 parent
5f062f3
commit f1d4608
Showing
4 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ Chapter 10: 29/29 | |
|
||
Chapter 11: 15/15 | ||
|
||
Chapter 12: 0/37 | ||
Chapter 12: 1/37 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// UVa12538 Version Controlled IDE | ||
// Rujia Liu | ||
// This code makes use of rope, a persistent string available in gcc's STL extensions. | ||
#include<cstdio> | ||
#include<iostream> | ||
#include<ext/rope> | ||
using namespace std; | ||
using namespace __gnu_cxx; | ||
|
||
const int maxn = 50000 + 5; | ||
const int maxlen = 100000 + 5; | ||
|
||
crope cur, versions[maxn]; | ||
char s[maxlen]; | ||
|
||
int main() { | ||
int n; | ||
scanf("%d", &n); // a single test case | ||
int d = 0; | ||
int vnow = 0; | ||
while(n--) { | ||
int op, p, c, v; | ||
scanf("%d", &op); | ||
if(op == 1) { | ||
scanf("%d%s", &p, s); | ||
p -= d; | ||
cur.insert(p, s); | ||
versions[++vnow] = cur; | ||
} | ||
else if(op == 2) { | ||
scanf("%d%d", &p, &c); | ||
p -= d; c -= d; | ||
cur.erase(p-1, c); | ||
versions[++vnow] = cur; | ||
} | ||
else { | ||
scanf("%d%d%d", &v, &p, &c); | ||
p -= d; v -= d; c -= d; | ||
crope r = versions[v].substr(p-1, c); | ||
d += count(r.begin(), r.end(), 'c'); | ||
cout << r << "\n"; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters