|
|
вернуться в форумWA6, Help, give me test,please. Help, give me test,please. My code,it worked for every test, but WA6: #include "iostream" #include "stdio.h" #include "deque" #include "string" using namespace std; int main() { std::deque<char> deq(0);
std::string line; std::getline(std::cin, line); for (int i= 0; i < line.size(); i++) { deq.push_back (line[i]); } deque<char>::size_type sz = deq.size(); for (int i=0; i<sz; i++) { if (i+1 != sz) { if (deq[i] == deq[i+1]) { deq.erase(deq.begin()+i,deq.begin()+(i+2)); if (i>0) i -=2; sz = deq.size(); continue; } } else if ((i-1)!=-1) { if (deq[i-1] == deq[i]) { deq.erase(deq.begin()+i-1,deq.begin()+(i+1)); if (i>0) i -=2; sz = deq.size(); continue; } } } for (int i=0; i<deq.size(); i++) cout << deq[i]; cout << endl; return 0; } |
|
|