Skip to content
Snippets Groups Projects
Commit aa13c817 authored by Josef Atoui's avatar Josef Atoui
Browse files

icanguessthedatastructure solved with 0.03 s

parent 173cf6d8
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ object_script.*.Debug ...@@ -16,6 +16,7 @@ object_script.*.Debug
*_plugin_import.cpp *_plugin_import.cpp
/.qmake.cache /.qmake.cache
/.qmake.stash /.qmake.stash
*.pro
*.pro.* *.pro.*
*.pro.user *.pro.user
*.pro.user.* *.pro.user.*
...@@ -42,4 +43,4 @@ target_wrapper.* ...@@ -42,4 +43,4 @@ target_wrapper.*
*.qmlproject.user.* *.qmlproject.user.*
# QtCreator CMake # QtCreator CMake
CMakeLists.txt.user* CMakeLists.txt.user*
\ No newline at end of file
#include <iostream> #include <iostream>
#include <stack> #include <stack>
#include <queue> #include <queue>
#include <fstream>
using namespace std; using namespace std;
...@@ -18,15 +18,15 @@ using namespace std; ...@@ -18,15 +18,15 @@ using namespace std;
int main() { int main() {
string input; int input;
int cmdLines = 0; int cmdLines = 0;
bool isQueue; bool isQueue;
bool isStack; bool isStack;
bool isPQueue; bool isPQueue;
ifstream myfile("example.in");
while (getline(myfile, input)) { while (cin >> input) {
queue<int> q; queue<int> q;
priority_queue<int> pq; priority_queue<int> pq;
...@@ -35,18 +35,13 @@ int main() { ...@@ -35,18 +35,13 @@ int main() {
isPQueue = true; isPQueue = true;
isStack = true; isStack = true;
if (input.size() == 1) { cmdLines = input;
cmdLines = stoi(input);
}
if (cmdLines == 0) {
return 0;
}
for (int i = 0; i < cmdLines; i++) { for (int i = 0; i < cmdLines; i++) {
getline(myfile, input); int value;
cin >> input;
int value = stoi(input.substr(2, 3)); cin >> value;
if (stoi(input.substr(0, 1)) == ADD) { if (input == ADD) {
if (isQueue) q.push(value); if (isQueue) q.push(value);
if (isPQueue) pq.push(value); if (isPQueue) pq.push(value);
if (isStack) s.push(value); if (isStack) s.push(value);
...@@ -83,6 +78,5 @@ int main() { ...@@ -83,6 +78,5 @@ int main() {
} }
//cout << endl;
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment