Increase array limitEach test case is a single line containing at least one and at most 100,000 letters
Code: Select all
strt[100010]
Moderator: Board moderators
Increase array limitEach test case is a single line containing at least one and at most 100,000 letters
Code: Select all
strt[100010]
It will be good if you remove all your codes after getting accepted.v1n1t wrote:I'm enclosing links to the input / output that brianfry713 mentioned above and that I found very useful during testing / debugging. I'm unable to post the actual input and output here since it's too big.Try the gift I/O, the link is at:
http://uva.onlinejudge.org/index.php?op ... ontest=278
(Link to) Input:
http://pastebin.com/33Yd2Xz2
(Link to) AC Output:
http://pastebin.com/2gRmgyZB
Code: Select all
class Main {
public static void main(String args[]) throws IOException {
PrintWriter out = new PrintWriter(System.out);
Scanner sc = new Scanner(System.in);
boolean isHome = false;
while(sc.hasNext()) {
char[] inputChars = sc.nextLine().toCharArray();
LinkedList<Character> beijuText = new LinkedList<Character>();
ListIterator<Character> it = beijuText.listIterator();
for(Character c : inputChars) {
if (c == '[') {
isHome = true;
it = beijuText.listIterator(0);
continue;
}
if (c == ']') {
isHome = false;
continue;
}
if (!isHome) {
beijuText.add(c);
} else {
it.add(c);
}
}
for (Character c1 : beijuText) {
out.print(c1);
}
out.print("\n");
}
out.close();
sc.close();
}
}
Code: Select all
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define FN(s,c) (int)s.find(c)
/*************************************************/
struct node {
char c;
node* next;
};
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
string a;
while (getline(cin, a)) {
char c = ']';
node* head = NULL;
node* tail = NULL;
node* temp_head = NULL;
node* temp_tail = NULL;
for (int i = 0; i < SZ(a); ++i) {
if (a[i] == '[') {
c = '[';
if (temp_head != NULL) {
head = temp_head;
temp_head = NULL;
temp_tail = NULL;
}
continue;
}
if (a[i] == ']') {
c = ']';
if (temp_head != NULL) {
head = temp_head;
temp_head = NULL;
temp_tail = NULL;
}
continue;
}
node* temp = new node;
temp->c = a[i];
// push_back
if (c == ']') {
temp->next = NULL;
if (head == NULL) {
head = temp;
tail = temp;
} else {
tail->next = temp;
tail = temp;
}
}
//push_front
else {
temp->next = head;
if (temp_head == NULL) {
temp_head = temp;
temp_tail = temp;
} else {
temp_tail->next = temp;
temp_tail = temp;
}
}
}
if (temp_head != NULL) {
head = temp_head;
}
//print the line
node* ptr = head;
while (ptr != NULL) {
cout << ptr->c;
ptr = ptr->next;
}
cout << endl;
}
return 0;
}