buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <iostream> using namespace std; int top = 0; // 最後の要素の位置 int S[1000]; // Stackのデータ // topにxを追加する void push(int x) { // topを加算してからSのその位置へ挿入 top++; S[top] = x; } // topから要素を取り出す int pop() { // topが指していた要素を返す int res = S[top]; top--; return res; } int main() { // 読み込んだ1シンボル(オペランドや演算子) char s...
#include <iostream> using namespace std; int top = 0; // 最後の要素の位置 int S[1000]; // Stackのデータ // topにxを追加する void push(int x) { // topを加算してからSのその位置へ挿入 top++; S[top] = x; } // topから要素を取り出す int pop() { // topが指していた要素を返す int res = S[top]; top--; return res; } int main() { // 読み込んだ1シンボル(オペランドや演算子) char s...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
211
4
#include <cstdlib> #include <iostream> #include <string> using namespace std; class Stack { private: int sp; int data[100]; public: Stack() { sp = 0; } void push(int x) { data[sp] = x; sp++; } int top() { return data[sp - 1]; } void pop() { sp--; } }; string str; int input_num(int *i) { char...
#include <cstdlib> #include <iostream> #include <string> using namespace std; class Stack { private: int sp; int data[100]; public: Stack() { sp = 0; } void push(int x) { data[sp] = x; sp++; } int top() { return data[sp - 1]; } void pop() { sp--; } }; string str; int input_num(int *i) { char...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 5, 0, 62]]
1
386
3
#include <iostream> #include <sstream> #include <string> using namespace std; class Stack { private: int sp; int S[100]; public: Stack() { sp = 0; } bool isFull() const { return (sp == 100); } bool isEmpty() const { return (sp == 0); } void push(int d); int top(); void pop(); }; void Stack::push(int ...
#include <iostream> #include <sstream> #include <string> using namespace std; class Stack { private: int sp; int S[100]; public: Stack() { sp = 0; } bool isFull() const { return (sp == 100); } bool isEmpty() const { return (sp == 0); } void push(int d); int top(); void pop(); }; void Stack::push(int ...
[["-", 0, 99, 8, 9, 0, 100, 0, 97, 128, 129], ["+", 8, 9, 0, 99, 8, 9, 0, 100, 0, 162], ["-", 0, 1, 0, 2, 63, 343, 345, 348, 0, 349]]
1
376
3
#include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> st; int a, b; string s; while (cin >> s) { if (s == "+") { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(a + b); } else if (s == "-") { a = st.top(); ...
#include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> st; int a, b; string s; while (cin >> s) { if (s == "+") { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(a + b); } else if (s == "-") { a = st.top(); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
207
4
#include <stack> #include <stdio.h> #include <stdlib.h> using namespace std; int main() { int a, b; char s[100]; stack<int> S; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = S.top(); S.pop(); b = S.top(); S.pop(); S.push(a + b); } else if (s[0] == '-') { b =...
#include <stack> #include <stdio.h> #include <stdlib.h> using namespace std; int main() { int a, b; char s[100]; stack<int> S; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = S.top(); S.pop(); b = S.top(); S.pop(); S.push(a + b); } else if (s[0] == '-') { b =...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
229
3
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; #define MAX 100 #define max 1000000 void initialize(); int isEmpty(); int isFull(); void push(int); int pop(); int top; int S[max]; int main() { char c[max]; int sum = 0; int a, b; initialize(); while (cin >> c) { if (c[0] ...
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; #define MAX 200 #define max 1000000 void initialize(); int isEmpty(); int isFull(); void push(int); int pop(); int top; int S[max]; int main() { char c[max]; int sum = 0; int a, b; initialize(); while (cin >> c) { if (c[0] ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
307
6
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <stack> using namespace std; int main() { int x[200] = {}; int i = 0; char str[20] = {}; while (cin >> str) { if (str[0] == '+') { x[i - 1] += x[i]; i--; } if (str[0] == '-') { ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <stack> using namespace std; int main() { int x[200] = {}; int i = 0; char str[20] = {}; while (cin >> str) { if (str[0] == '+') { x[i - 1] += x[i]; i--; } else if (str[0] == '-') { ...
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 12, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]]
1
174
6
#include <iostream> #include <string> using namespace std; int S[3]; int top = 0; void push(int x) { top += 1; S[top] = x; } int pop() { top -= 1; return S[top + 1]; } int main() { string c; int a, b; while (cin >> c) { if (c == "+") { a = pop(); b = pop(); push(a + b); } els...
#include <iostream> #include <string> using namespace std; int S[200]; int top = 0; void push(int x) { top += 1; S[top] = x; } int pop() { top -= 1; return S[top + 1]; } int main() { string c; int a, b; while (cin >> c) { if (c == "+") { a = pop(); b = pop(); push(a + b); } e...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
190
6
#include <fstream> #include <iostream> #include <string> using namespace std; int S[200]; int top = 0; void push(int x) { S[top++] = x; } int pop() { return S[--top]; } int main() { string s; char c; int a, b; // cin >> s; // getline(cin, s); // int i=0; // cout << s << endl; // for (char& c: s) { ...
#include <fstream> #include <iostream> #include <string> using namespace std; int S[200]; int top = 0; void push(int x) { S[top++] = x; } int pop() { return S[--top]; } int main() { string s; char c; int a, b; // cin >> s; // getline(cin, s); // int i=0; // cout << s << endl; // for (char& c: s) { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
238
4
#include <iostream> #include <stdlib.h> using namespace std; const int Max = 300; int Stack[Max]; int top = 0; bool isFull() { return (top >= Max); } bool isEmpty() { return top == 0; } int push(int x) { if (!isFull()) { Stack[top++] = x; } } int pop() { if (!isEmpty()) return Stack[--top]; } int main()...
#include <iostream> #include <stdlib.h> using namespace std; const int Max = 300; int Stack[Max]; int top = 0; bool isFull() { return (top >= Max); } bool isEmpty() { return top == 0; } void push(int x) { if (!isFull()) { Stack[top++] = x; } } int pop() { if (!isEmpty()) return Stack[--top]; } int main()...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
243
6
#include <iostream> #include <stack> #include <string> #include <typeinfo> using namespace std; int main(void) { string num; int a, b; stack<int> st; while (cin >> num) { if (num == "+") { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(a + b); } else if (num == "-"...
#include <iostream> #include <stack> #include <string> #include <typeinfo> using namespace std; int main(void) { string num; int a, b; stack<int> st; while (cin >> num) { if (num == "+") { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(a + b); } else if (num == "-"...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
210
4
#include <cstdio> #include <cstdlib> #include <stack> using namespace std; int main(void) { stack<int> st; char mozsu[10] = {0}; int hen = 0; int aa = 0; int bb = 0; while (scanf("%s", mozsu) != EOF) { switch (mozsu[0]) { case '+': aa = st.top(); st.pop(); bb = st.top(); st...
#include <cstdio> #include <cstdlib> #include <stack> using namespace std; int main(void) { stack<int> st; char mozsu[10] = {0}; int hen = 0; int aa = 0; int bb = 0; while (scanf("%s", mozsu) != EOF) { switch (mozsu[0]) { case '+': aa = st.top(); st.pop(); bb = st.top(); st...
[["-", 0, 100, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 100, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 100, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 100, 0, 1, 0, 11, 12, 16, 12, 22]]
1
255
4
#include <iostream> #include <sstream> #include <stack> using namespace std; int main() { ios::sync_with_stdio(false); string c; stack<int> st; while (cin >> c) { if (c == "+") { int i1 = st.top(); st.pop(); int i2 = st.top(); st.pop(); st.push(i1 + i2); } else if (c == "...
#include <iostream> #include <sstream> #include <stack> using namespace std; int main() { ios::sync_with_stdio(false); string c; stack<int> st; while (cin >> c) { if (c == "+") { int i2 = st.top(); st.pop(); int i1 = st.top(); st.pop(); st.push(i1 + i2); } else if (c == "...
[["-", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22]]
1
232
12
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> s; int x, y, z; string ret; while (cin >> ret) { if (ret == "+" || ret == "-" || ret == "*" || ret == "/") { x = s.top(); s.pop(); y = s.top(); s.pop(); swit...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> s; int x, y, z; string ret; while (cin >> ret) { if (ret == "+" || ret == "-" || ret == "*" || ret == "/") { y = s.top(); s.pop(); x = s.top(); s.pop(); swit...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
193
4
const input = require('fs').readFileSync('/dev/stdin', 'utf8'); const list = input.trim().split('\n'); let [n, q] = list.shift().split(' '); n = Number(n); q = Number(q); class Process { constructor(name, time) { this.name = name; this.time = time; } } const queue = []; for (let i = 1; i < n; i++) { co...
const input = require('fs').readFileSync('/dev/stdin', 'utf8'); const list = input.trim().split('\n'); let [n, q] = list.shift().split(' '); n = Number(n); q = Number(q); class Process { constructor(name, time) { this.name = name; this.time = time; } } const queue = []; for (let i = 0; i < n; i++) { co...
[["-", 0, 493, 0, 7, 10, 570, 0, 200, 51, 555], ["+", 0, 493, 0, 7, 10, 570, 0, 200, 51, 555]]
2
238
2
#include <cstdio> #include <cstdlib> class stack { int top; int s[100]; public: stack() : top(0), s() {} void push(int x) { s[++top] = x; } int pop() { return s[(top--) + 1]; } }; int main() { int a, b, x; char s[100]; stack st; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = st.po...
#include <cstdio> #include <cstdlib> class stack { int top; int s[100]; public: stack() : top(0), s() {} void push(int x) { s[++top] = x; } int pop() { return s[top--]; } }; int main() { int a, b, x; char s[100]; stack st; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = st.pop(); ...
[["-", 0, 69, 341, 342, 0, 16, 31, 23, 0, 24], ["-", 0, 69, 341, 342, 0, 16, 31, 23, 0, 25], ["-", 0, 37, 0, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 37, 0, 69, 341, 342, 0, 16, 12, 13]]
1
254
4
#include <cstdio> #include <cstdlib> template <typename T> class stack { T a[101]; unsigned n; public: stack() : a(), n(0) {} T &top() { return a[n - 1]; } T pop() { return a[n--]; } void push(T in) { a[n++] = in; } }; int main() { stack<int> s; char buf[100]; while (scanf("%s", buf) != EOF) { ...
#include <cstdio> #include <cstdlib> template <typename T> class stack { T a[101]; unsigned n; public: stack() : a(), n(0) {} T &top() { return a[n - 1]; } T pop() { return a[--n]; } void push(T in) { a[n++] = in; } }; int main() { stack<int> s; char buf[100]; while (scanf("%s", buf) != EOF) { ...
[["-", 0, 37, 0, 69, 341, 342, 0, 27, 28, 22], ["+", 0, 37, 0, 69, 341, 342, 0, 27, 28, 22]]
1
223
22
#include <cstdio> #include <cstdlib> #include <cstring> using namespace std; int top, S[1000]; void push(int x) { top++; S[top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); ...
#include <cstdio> #include <cstdlib> #include <cstring> using namespace std; int top, S[1000]; void push(int x) { top++; S[top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
213
4
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { int n = S.top(); S.pop(); n += S.top(); S.pop(); S.push(n); } else if (word == "-") { int s = ...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { int n = S.top(); S.pop(); n += S.top(); S.pop(); S.push(n); } else if (word == "-") { int s = ...
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
204
2
#include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> S; string buf; while (cin >> buf) { if (buf == "+") { int a = S.top(); S.pop(); int b = S.top(); S.pop(); S.push(a + b); } else if (buf == "-") { int a = S.top(); ...
#include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> S; string buf; while (cin >> buf) { if (buf == "+") { int b = S.top(); S.pop(); int a = S.top(); S.pop(); S.push(a + b); } else if (buf == "-") { int b = S.top(); ...
[["-", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22]]
1
205
12
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> data; string str[1000]; int a; int b1; int b2; int c = 0; while (cin >> str[c]) { if (str[c] != "+" && str[c] != "-" && str[c] != "*" && str[c] != "/") { a = atoi(str[c].c_str...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> data; string str[1000]; int a; int b1; int b2; int c = 0; while (cin >> str[c]) { if (str[c] != "+" && str[c] != "-" && str[c] != "*" && str[c] != "/") { a = atoi(str[c].c_str...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
282
4
#include <iostream> #include <stack> using namespace std; int main() { stack<int> iStack; string s; int a, b; while (cin >> s) { if (s == "+") { a = iStack.top(); iStack.pop(); b = iStack.top(); iStack.pop(); iStack.push(a + b); } else if (s == "*") { a = iStack.to...
#include <iostream> #include <stack> using namespace std; int main() { stack<int> iStack; string s; int a, b; while (cin >> s) { if (s == "+") { a = iStack.top(); iStack.pop(); b = iStack.top(); iStack.pop(); iStack.push(a + b); } else if (s == "*") { a = iStack.to...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
202
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
264
4
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main(void) { stack<int> stk; int a, b, x, num; string s; while (cin >> s) { if (s[0] == '+' || s[0] == '-' || s[0] == '*') { a = stk.top(); stk.pop(); b = stk.top(); stk.pop(); ...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main(void) { stack<int> stk; int a, b, x, num; string s; while (cin >> s) { if (s[0] == '+' || s[0] == '-' || s[0] == '*') { a = stk.top(); stk.pop(); b = stk.top(); stk.pop(); ...
[["-", 64, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 64, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 64, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 64, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
196
4
#include <iostream> #include <string> #include <vector> using namespace std; void showStack(vector<int> A) { for (int i = 0; i < A.size(); i++) { cout << A[i] << " "; } cout << endl; } int main() { vector<int> A; string input; while (cin >> input) { if (input[0] == '+') { int m = A[A.size(...
#include <iostream> #include <string> #include <vector> using namespace std; void showStack(vector<int> A) { for (int i = 0; i < A.size(); i++) { cout << A[i] << " "; } cout << endl; } int main() { vector<int> A; string input; while (cin >> input) { if (input[0] == '+') { int m = A[A.size(...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
292
4
#include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<int> A; string input; while (cin >> input) { if (input[0] == '+') { int m = A[A.size() - 1]; A.pop_back(); int n = A[A.size() - 1]; A.pop_back(); A.push_back(m + n); } else if ...
#include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<int> A; string input; while (cin >> input) { if (input[0] == '+') { int m = A[A.size() - 1]; A.pop_back(); int n = A[A.size() - 1]; A.pop_back(); A.push_back(m + n); } else if ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
246
4
#include <iostream> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; typedef struct calc { int *top; int *data; } calc_t; calc_t *init(int size) { calc_t *calc = (calc_t *)malloc(sizeof(calc_t)); calc->top = calc->data = (int *)malloc(sizeof(in...
#include <iostream> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; typedef struct calc { int *top; int *data; } calc_t; calc_t *init(int size) { calc_t *calc = (calc_t *)malloc(sizeof(calc_t)); calc->top = calc->data = (int *)malloc(sizeof(in...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
338
4
#include <iostream> #include <stack> #include <stdio.h> #include <stdlib.h> using namespace std; int main() { stack<int> intStack; char c[3]; while ((scanf("%s", &c)) != EOF) { if (c[0] == '+' || c[0] == '-' || c[0] == '*') { int in, a, b; b = intStack.top(); intStack.pop(); a = int...
#include <iostream> #include <stack> #include <stdio.h> #include <stdlib.h> using namespace std; int main() { stack<int> intStack; char c[5]; while ((scanf("%s", &c)) != EOF) { if (c[0] == '+' || c[0] == '-' || c[0] == '*') { int in, a, b; b = intStack.top(); intStack.pop(); a = int...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 100, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 0, 100, 0, 1, 0, 11, 12, 16, 17, 48]]
1
199
4
#include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { // ??°??????????¶???????????????\?????? int n = S.top(); S.pop(); n = n + S.top(); S.pop(); S.push(n); } else i...
#include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { // ??°??????????¶???????????????\?????? int n = S.top(); S.pop(); n = n + S.top(); S.pop(); S.push(n); } else i...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
207
4
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; int i, j; while (cin >> word) { if (word == "+") { i = S.top(); S.pop(); j = S.top(); S.pop(); S.push(i + j); } else if (word == "-"...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; int i, j; while (cin >> word) { if (word == "+") { i = S.top(); S.pop(); j = S.top(); S.pop(); S.push(i + j); } else if (word == "-"...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
215
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <stack> #include <string> #include <vector> using namespace std; int main(void) { string word; stack<int> S; while (cin >> word) { if (word == "+") { int a, b; a = S.top(); ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <stack> #include <string> #include <vector> using namespace std; int main(void) { string word; stack<int> S; while (cin >> word) { if (word == "+") { int a, b; a = S.top(); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
239
4
#include <bits/stdc++.h> using namespace std; int top, S[1000]; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char s[100]; while (cin >> s) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); } else if (s[0] == '-') {...
#include <bits/stdc++.h> using namespace std; int top, S[1000]; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char s[100]; while (cin >> s) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); } else if (s[0] == '-') {...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
196
4
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { //?¨?????????????????????????stack????????¨ stack<int> S; int a, b, x; string s; while (cin >> s) { if (s[0]...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { stack<int> S; int a, b, x; string s; while (cin >> s) { if (s[0] == '+') { a = S.top(); S.pop(); ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
236
4
#include <iostream> #include <stack> #include <string> using namespace std; int main() { string s; stack<int> st; while (cin >> s) { if (s == "+" || s == "-" || s == "*") { int n1, n2; n1 = st.top(); st.pop(); n2 = st.top(); st.pop(); if (s == "+") { st.push(n1 +...
#include <iostream> #include <stack> #include <string> using namespace std; int main() { string s; stack<int> st; while (cin >> s) { if (s == "+" || s == "-" || s == "*") { int n1, n2; n1 = st.top(); st.pop(); n2 = st.top(); st.pop(); if (s == "+") { st.push(n1 +...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
173
4
#include <stdio.h>} #include <stdlib.h> #include <string.h> int stack[200]; int it = 0; // push(6) // push(8) // push(10); // pop(); //[0] [1] [2] [3] ... // 6 8 10 void push(int x) { //???????????????x???????????§??????????????°???1????¶???? stack[it] = x; it++; } int pop() { //???????????°??????1??????...
#include <stdio.h>} #include <stdlib.h> #include <string.h> int stack[200]; int it = 0; void push(int x) { stack[it] = x; it++; } int pop() { it--; return stack[it]; } int main(void) { int a, b, i; char str[1000000]; while (scanf("%s", str) != EOF) { if (strcmp(str, "+") == 0) { a = pop();...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
265
4
#include <cstdlib> #include <iostream> using namespace std; #define MAX 1000 int A[MAX], top; void push(int x) { if (top >= MAX - 1) { cout << "?????????????????????"; } else { top++; A[top] = x; } } int pop() { if (top == 0) { cout << "??¢??????????????????"; return 0; } else { top...
#include <cstdlib> #include <iostream> using namespace std; #define MAX 1000 int A[MAX], top; void push(int x) { if (top >= MAX - 1) { cout << "?????????????????????"; } else { top++; A[top] = x; } } int pop() { if (top == 0) { cout << "??¢??????????????????"; return 0; } else { top...
[["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 13], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 73]]
1
244
3
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string str; stack<int> s; int a, b, n; while (cin >> str) { if (str == "+") { a = s.top(); s.pop(); b = s.top(); s.pop(); s.push(a + b); } else if (str == "-") { ...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string str; stack<int> s; int a, b, n; while (cin >> str) { if (str == "+") { a = s.top(); s.pop(); b = s.top(); s.pop(); s.push(a + b); } else if (str == "-") { ...
[["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 44], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
219
5
#include <cstdio> #include <iostream> #include <stack> #include <string.h> using namespace std; int main() { // your code goes here int ans = 0; stack<int> s; char r[10]; int a, b; while (scanf("%s", r) != EOF) { if (strcmp(r, "+") == 0) { a = s.top(); s.pop(); b = s.top(); s....
#include <cstdio> #include <iostream> #include <stack> #include <string.h> using namespace std; int main() { // your code goes here int ans = 0; stack<int> s; char r[10]; int a, b; while (scanf("%s", r) != EOF) { if (strcmp(r, "+") == 0) { a = s.top(); s.pop(); b = s.top(); s....
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
240
4
#include <iostream> #include <stack> using namespace std; int main() { string s; int b, c; stack<int> a; while (cin >> s) { if (s == "+") { b = a.top(); a.pop(); c = a.top(); a.pop(); a.push(b + c); } else if (s == "-") { b = a.top(); a.pop(); c = a.top(...
#include <iostream> #include <stack> using namespace std; int main() { string s; int b, c; stack<int> a; while (cin >> s) { if (s == "+") { b = a.top(); a.pop(); c = a.top(); a.pop(); a.push(b + c); } else if (s == "-") { b = a.top(); a.pop(); c = a.top(...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33]]
1
206
2
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int a, b; stack<int> st; string op; while (cin >> op) { cin >> op; if (isdigit(op[0])) st.push(stoi(op)); else...
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int a, b; stack<int> st; string op; while (cin >> op) { // cout << op << endl; if (isdigit(op[0])) st.push(stoi(op...
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
170
4
#include "bits/stdc++.h" using namespace std; int top, S[1000]; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); } else if...
#include "bits/stdc++.h" using namespace std; int top, S[1000]; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); } else if ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
209
4
#include <algorithm> #include <iostream> #include <sstream> #include <stack> #define ll long long using namespace std; int main() { string s; stack<ll> st; while (cin >> s) { if (s == "+") { ll a = st.top(); st.pop(); ll b = st.top(); st.pop(); st.push(a + b); } else if (s ...
#include <algorithm> #include <iostream> #include <sstream> #include <stack> #define ll long long using namespace std; int main() { string s; stack<ll> st; while (cin >> s) { if (s == "+") { ll a = st.top(); st.pop(); ll b = st.top(); st.pop(); st.push(a + b); } else if (s ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
221
4
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { // ??\?????????????????????????????? if (word == "+") { // ??°??? 2 ??? pop ??????????????? push ?????? int a, b; a = S.top(); S....
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { // ??\?????????????????????????????? if (word == "+") { // ??°??? 2 ??? pop ??????????????? push ?????? int a, b; a = S.top(); S....
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151]]
1
230
4
#include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> int top, S[1000]; int pop() { if (top == 0) { throw "stack is empty."; } return S[--top]; } void push(int x) { S[top++] = x; } int main() { int x; char s[100]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+'...
#include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> int top, S[1000]; int pop() { if (top == 0) { throw "stack is empty."; } return S[--top]; } void push(int x) { S[top++] = x; } int main() { int x; char s[100]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
226
4
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <sstream> #include <stack> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #defi...
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <sstream> #include <stack> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #defi...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
274
4
#include <cstdlib> #include <iostream> #include <math.h> #include <stack> #include <stdio.h> #include <string.h> using namespace std; class c_polish { private: public: c_polish(); void f_input(); }; c_polish::c_polish() {} void c_polish::f_input() { string s[200]; long i; long data0; stack<long> data1; ...
#include <cstdlib> #include <iostream> #include <math.h> #include <stack> #include <stdio.h> #include <string.h> using namespace std; class c_polish { private: public: c_polish(); void f_input(); }; c_polish::c_polish() {} void c_polish::f_input() { string s[200]; long i; long data0; stack<long> data1; ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
309
4
#include <cstdlib> #include <deque> #include <iostream> using namespace std; int main(void) { deque<int> st; string formula; int a, b; while (1) { cin >> formula; if (cin.eof()) break; char c = *formula.c_str(); switch (c) { case '+': a = st[st.size() - 1]; b = st...
#include <cstdlib> #include <deque> #include <iostream> using namespace std; int main(void) { deque<int> st; string formula; int a, b; while (1) { cin >> formula; if (cin.eof()) break; char c = *formula.c_str(); switch (c) { case '+': a = st[st.size() - 2]; b = st...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
297
12
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; int top = 0, S[1000]; int pop() { top--; return S[top + 1]; } void push(int x) { S[++top] = x; } int main() { char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { int a = pop(); int ...
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; int top = 0, S[1000]; int pop() { top--; return S[top + 1]; } void push(int x) { S[++top] = x; } int main() { char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { int a = pop(); int ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
214
4
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int S[1000], top; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; char s[100]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int S[1000], top; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; char s[100]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
209
4
#include <cstdlib> #include <iostream> using namespace std; int S[1000], top; void push(int i) { S[top] = i; top++; } int pop() { int i = S[top--]; top--; return i; } int main() { int i, j; char c[100]; while (cin >> c) { if (c[0] == '+') { i = pop(); j = pop(); push(i + j); } ...
#include <cstdlib> #include <iostream> using namespace std; int S[1000], top; void push(int i) { S[top] = i; top++; } int pop() { int i = S[top - 1]; top--; return i; } int main() { int i, j; char c[100]; while (cin >> c) { if (c[0] == '+') { i = pop(); j = pop(); push(i + j); ...
[["-", 49, 50, 51, 69, 341, 342, 0, 27, 17, 68], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 17, 33], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 12, 13]]
1
198
3
#include <algorithm> #include <iostream> #include <limits> #include <stack> #include <string> #include <vector> #define INT_MAX 2147483647 #define INT_MIN -2147483647 using namespace std; void print(vector<pair<char, int>> &data) { for (int i = 0; i < data.size() - 1; ++i) cout << data[i].first << data[i].secon...
#include <algorithm> #include <iostream> #include <limits> #include <stack> #include <string> #include <vector> #define INT_MAX 2147483647 #define INT_MIN -2147483647 using namespace std; void print(vector<pair<char, int>> &data) { for (int i = 0; i < data.size() - 1; ++i) cout << data[i].first << data[i].secon...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22]]
1
273
4
#include <stdio.h> #include <stdlib.h> char stack[200]; int top = 0; bool isFull() { if (top == 199) { return true; } return false; } bool isEmpty() { if (top == -1) { return true; } return false; } int pop() { if (isEmpty()) { printf("Stack is empty.\n"); exit(EXIT_FAILURE); } ret...
#include <stdio.h> #include <stdlib.h> int stack[100]; int top = 0; bool isFull() { if (top == 199) { return true; } return false; } bool isEmpty() { if (top == -1) { return true; } return false; } int pop() { if (isEmpty()) { printf("Stack is empty.\n"); exit(EXIT_FAILURE); } retu...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 37, 0, 69, 341, 342, 0, 27, 28, 22], ["+", 0, 37, 0, 69, 341, 342, 0, 27, 28, 22]]
1
300
6
#include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { double a = S.top(); S.pop(); double b = S.top(); S.pop(); S.push(a + b); } else if (word == "-") { double a = S....
#include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { double a = S.top(); S.pop(); double b = S.top(); S.pop(); S.push(a + b); } else if (word == "-") { double a = S....
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
210
2
#include <cctype> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; const int MAX = 100; int top, s[MAX + 1]; void initialize() { top = 0; } bool isEmpty() { return top == 0; } bool isFull() { return top >= MAX; } void push(int x) { if (isFull()) { fprintf(stderr...
#include <cctype> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; const int MAX = 100; int top, s[MAX + 1]; void initialize() { top = 0; } bool isEmpty() { return top == 0; } bool isFull() { return top >= MAX; } void push(int x) { if (isFull()) { fprintf(stderr...
[["-", 75, 76, 0, 9, 0, 43, 49, 50, 49, 22], ["+", 75, 76, 0, 9, 0, 43, 49, 50, 49, 22]]
1
267
4
#include <iostream> #include <stack> #include <stdlib.h> #include <string> using namespace std; int main() { stack<int> S; string ch; int a, b; while (cin >> ch) { switch (ch[0]) { case '+': a = S.top(); S.pop(); b = S.top(); S.pop(); S.push(a + b); break; case ...
#include <iostream> #include <stack> #include <stdlib.h> #include <string> using namespace std; int main() { stack<int> S; string ch; int a, b; while (cin >> ch) { switch (ch[0]) { case '+': a = S.top(); S.pop(); b = S.top(); S.pop(); S.push(a + b); break; case ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
210
4
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int top, S[1000]; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char ch[100]; while (scanf("%s", ch) != EOF) { if (ch[0] == '+') { a ...
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int top, S[1000]; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; top = 0; char ch[100]; while (scanf("%s", ch) != EOF) { if (ch[0] == '+') { a ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
209
4
#include <algorithm> #include <cstdlib> #include <iostream> #include <stdio.h> using namespace std; int S[1000], top; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { string st; int a, b; top = 0; while (cin >> st) { if (st == "+") { a = pop(); b = ...
#include <algorithm> #include <cstdlib> #include <iostream> #include <stdio.h> using namespace std; int S[1000], top; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { string st; int a, b; top = 0; while (cin >> st) { if (st == "+") { a = pop(); b = ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
203
4
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int S[1000], top; void push(int x) { S[top++] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; char s[200]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(...
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int S[1000], top; void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } int main() { int a, b; char s[200]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(...
[["-", 0, 11, 31, 69, 341, 342, 0, 27, 28, 22], ["+", 0, 11, 31, 69, 341, 342, 0, 27, 28, 22]]
1
211
2
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <vector> #define Max_N 100 using namespace std; int V[Max_N]; int top = 0; int pop(int ...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <vector> #define Max_N 100 using namespace std; int V[Max_N]; int top = 0; int pop(int ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
250
4
#include <cstdlib> #include <iostream> using std::cin; using std::cout; using std::endl; #include <stack> using std::stack; #include <string> using std::string; int main() { stack<int> S; string s; int v1, v2; while (cin >> s) { if (s[0] == '+') { v1 = S.top(); S.pop(); v2 = S.top(); ...
#include <cstdlib> #include <iostream> using std::cin; using std::cout; using std::endl; #include <stack> using std::stack; #include <string> using std::string; int main() { stack<int> S; string s; int v1, v2; while (cin >> s) { if (s[0] == '+') { v1 = S.top(); S.pop(); v2 = S.top(); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
240
4
#include <ctype.h> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> st; string s; while (cin >> s) { char c = s[0]; if (isdigit(c)) { st.push(stoi(s)); } else { int x = st.top(); st.pop(); int y = st.top(); st.pop(); ...
#include <ctype.h> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> st; string s; while (cin >> s) { char c = s[0]; if (isdigit(c)) { st.push(stoi(s)); } else { int y = st.top(); st.pop(); int x = st.top(); st.pop(); ...
[["-", 75, 76, 0, 9, 0, 43, 49, 50, 49, 22], ["+", 75, 76, 0, 9, 0, 43, 49, 50, 49, 22]]
1
179
4
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> st; int a, b; string s; while (cin >> s) if (s[0] == '+') { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(a + b); } else if (s[0] == '-') { ...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> st; int a, b; string s; while (cin >> s) if (s[0] == '+') { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(a + b); } else if (s[0] == '-') { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
217
4
#include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; struct Stack { int pointer; int *data; Stack(int size) { this->data = new int[size]; this->pointer = -1; } void push(int val) { this->pointer++; this->data[pointer] = val; } int pop() { if...
#include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; struct Stack { int pointer; int *data; Stack(int size) { this->data = new int[size]; this->pointer = -1; } void push(int val) { this->pointer++; this->data[pointer] = val; } int pop() { if...
[["-", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 75, 76, 0, 9, 0, 43, 49, 50, 49, 22], ["+", 75, 76, 0, 9, 0, 43, 49, 50, 49, 22]]
1
377
6
#include <iostream> #include <sstream> #include <stack> #include <string> using namespace std; int main() { string str; getline(cin, str); stack<int> sta; stringstream ss(str); string item; while (getline(ss, item, ' ')) { if ('0' < item[0] && item[0] < '9') { sta.push(stoi(item)); contin...
#include <iostream> #include <sstream> #include <stack> #include <string> using namespace std; int main() { string str; getline(cin, str); stack<int> sta; stringstream ss(str); string item; while (getline(ss, item, ' ')) { if ('0' <= item[0] && item[0] <= '9') { sta.push(stoi(item)); cont...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19]]
1
196
4
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int s[1000], top = 0; void push(int x) { s[++top] = x; } int pop() { --top; return s[top + 1]; } int main() { int c, b; char a[100]; while (scanf("%s", a)) { if (a[0] == '+') { b = pop(); c = ...
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int s[1000], top = 0; void push(int x) { s[++top] = x; } int pop() { --top; return s[top + 1]; } int main() { int c, b; char a[100]; while (scanf("%s", a) != EOF) { if (a[0] == '+') { b = pop(); ...
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
209
2
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <queue> #include <stdio.h> #include <string.h> using namespace std; stack<int> d; int tag[50005]; int main() { char a[100]; int x, y; while (cin >> a) { if (a[0] == '-') { x = d.top(); d.pop(); y = d.top(); d....
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <queue> #include <stdio.h> #include <string.h> using namespace std; stack<int> d; int tag[50005]; int main() { char a[100]; int x, y; while (cin >> a) { if (a[0] == '-') { x = d.top(); d.pop(); y = d.top(); d....
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
277
4
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <queue> #include <stdio.h> #include <string.h> using namespace std; stack<int> d; int tag[50005]; int popo(stack<int> &x) { int y = x.top(); x.pop(); return y; } int main() { char a[100]; int x, y; while (cin >> a) { if (a[0] ==...
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <queue> #include <stdio.h> #include <string.h> using namespace std; stack<int> d; int tag[50005]; int popo(stack<int> &x) { int y = x.top(); x.pop(); return y; } int main() { char a[100]; int x, y; while (cin >> a) { if (a[0] ==...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
251
4
#include <bits/stdc++.h> using namespace std; int main() { string s; int a, b; stack<int> st; while (cin >> s) { if (s[0] == '+') { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(b + a); } else if (s[0] == '*') { a = st.top(); st.pop(); b = st.to...
#include <bits/stdc++.h> using namespace std; int main() { string s; int a, b; stack<int> st; while (cin >> s) { if (s[0] == '+') { a = st.top(); st.pop(); b = st.top(); st.pop(); st.push(b + a); } else if (s[0] == '*') { a = st.top(); st.pop(); b = st.to...
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
213
2
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { int a, b; string s; stack<int> t; while (cin >> s) { if (s[0] == '+') { a = t.top(); t.pop(); b = t.top(); t.pop(); t.push(a + b); } else if (s[0] == '-') { a ...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { int a, b; string s; stack<int> t; while (cin >> s) { if (s[0] == '+') { a = t.top(); t.pop(); b = t.top(); t.pop(); t.push(a + b); } else if (s[0] == '-') { a ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
220
4
#include <algorithm> #include <iostream> #include <stack> #include <string> using namespace std; main() { int a, b; string str; stack<int> s; while (cin >> str) { if ('+' == str[0]) { a = s.top(); s.pop(); b = s.top(); s.pop(); s.push(a + b); } else if ('-' == str[0]) { ...
#include <algorithm> #include <iostream> #include <stack> #include <string> using namespace std; main() { int a, b; string str; stack<int> s; while (cin >> str) { if ('+' == str[0]) { a = s.top(); s.pop(); b = s.top(); s.pop(); s.push(a + b); } else if ('-' == str[0]) { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
221
4
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <utility> #include <vector> constexpr int MOD = 1000000007; constexpr int INF = 2000000000; int main() { std::string str; std::stack<int> s; ...
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <utility> #include <vector> constexpr int MOD = 1000000007; constexpr int INF = 2000000000; int main() { std::string str; std::stack<int> s; ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
240
4
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { int a = S.top(); S.pop(); int b = S.top(); S.pop(); S.push(a + b); } else if (word == "-") { ...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string word; stack<int> S; while (cin >> word) { if (word == "+") { int a = S.top(); S.pop(); int b = S.top(); S.pop(); S.push(a + b); } else if (word == "-") { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
215
10
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> mystack; string in; while (cin >> in) { if (in == "+") { int x = mystack.top(); mystack.pop(); int y = mystack.top(); mystack.pop(); int z = x + y; mysta...
#include <cstdlib> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<int> mystack; string in; while (cin >> in) { if (in == "+") { int x = mystack.top(); mystack.pop(); int y = mystack.top(); mystack.pop(); int z = x + y; mysta...
[["-", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 64, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
229
4
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 200 #define Max 1000000 int top; int S[N]; int pop() { return S[top--]; } void init() { top = 0; } void push(int x) { S[++top] = x; } int main() { char s[Max]; int a, b; init(); while (scanf("%s", s) != EOF) { if (!strcmp(s, "+")) { ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 200 #define Max 1000000 int top; int S[N]; int pop() { return S[top--]; } void init() { top = 0; } void push(int x) { S[++top] = x; } int main() { char s[Max]; int a, b; init(); while (scanf("%s", s) != EOF) { if (!strcmp(s, "+")) { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
223
4
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin...
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegi...
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
306
2
#include <cstdlib> #include <iostream> #include <stack> using namespace std; int main(void) { stack<int> S; string s; int x; int y; while (cin >> s) { if (s == "+") { x = S.top(); S.pop(); y = S.top(); S.pop(); S.push(x + y); } else if (s == "-") { x = S.top(); ...
#include <cstdlib> #include <iostream> #include <stack> using namespace std; int main(void) { stack<int> S; string s; int x; int y; while (cin >> s) { if (s == "+") { x = S.top(); S.pop(); y = S.top(); S.pop(); S.push(x + y); } else if (s == "-") { x = S.top(); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
210
4
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cstdio> #include <cstdlib> #include <string> #include <vector> using namespace std; int top, S[101]; void initialize() { top = 0; } bool isEmpty() { return top == 0; } bool isFull() { return top == 100; } void push(int x) { if (isFull()) { printf("...
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cstdio> #include <cstdlib> #include <string> #include <vector> using namespace std; int top, S[101]; void initialize() { top = 0; } bool isEmpty() { return top == 0; } bool isFull() { return top == 100; } void push(int x) { if (isFull()) { printf("...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13]]
1
289
4
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 1000 int push(int A[], int *top, int val) { if (*top == MAX - 1) return 0; A[++(*top)] = val; return val; } int pop(int A[], int *top) { if (*top == 0) return 0; (*top)--; return A[(*top) + 1]; } int main() { int arr[1000], ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 1000 int push(int A[], int *top, int val) { if (*top == MAX - 1) return 0; A[++(*top)] = val; return val; } int pop(int A[], int *top) { if (*top == 0) return 0; (*top)--; return A[(*top) + 1]; } int main() { int arr[1000], ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
307
4
n=gets.to_i-1 a=gets.split b=*a r=0..n r.map{|i|n.downto(i+1){|j|a[k=j-1][1]>a[j][1]&&(a[k,2]=a[j],a[k])}} r.map{|i|m=i (m..n).map{|j|b[m][1]>b[j][1]&&m=j} b[i],b[m]=b[m],b[i]} puts a*" ",s=:Stable,b*" ",a==b ?s:"Not #{s}"
n=gets.to_i-1 a=gets.split b=*a r=0..n r.map{|i|n.downto(i+1){|j|a[k=j-1][1]>a[j][1]&&(a[k,2]=a[j],a[k])}} r.map{|i|m=i (m..n).map{|j|b[m][1]>b[j][1]&&m=j} b[i],b[m]=b[m],b[i]} puts a*" ",s=:Stable,b*" ",a==b ?s: 'Not stable'
[["-", 0, 652, 3, 4, 0, 754, 75, 557, 0, 62], ["-", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6], ["-", 3, 4, 0, 754, 75, 557, 0, 284, 0, 775], ["-", 3, 4, 0, 754, 75, 557, 0, 284, 0, 22], ["-", 3, 4, 0, 754, 75, 557, 0, 284, 0, 46], ["+", 0, 652, 3, 4, 0, 754, 75, 557, 0, 62], ["+", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6]]
4
170
9
def bubble_sort(array) a = array.dup (0...a.size).each do |i| (i + 1...a.size).reverse_each do |j| if a[j][1] < a[j - 1][1] a[j], a[j - 1] = a[j - 1], a[j] end end end a end def selection_sort(array) a = array.dup (0...a.size).each do |i| mini = i (i...a.size).each do |j...
def bubble_sort(array) a = array.dup (0...a.size).each do |i| (i + 1...a.size).reverse_each do |j| if a[j][1] < a[j - 1][1] a[j], a[j - 1] = a[j - 1], a[j] end end end a end def selection_sort(array) a = array.dup (0...a.size).each do |i| mini = i (i...a.size).each do |j...
[["-", 0, 493, 0, 652, 3, 4, 0, 652, 486, 22], ["+", 0, 493, 0, 652, 3, 4, 0, 652, 486, 22]]
4
221
2
def bubble_sort(a) arr = a.dup n = arr.length for i in 0..n - 1 j = n - 1 while j > i if arr[j-1][1] > arr[j][1] arr[j-1],arr[j] = arr[j],arr[j-1] end j -= 1 end end arr end def selection_sort(arr) a = arr.dup for i in 0..(a.length - 1) min = i for j in i ..(...
def bubble_sort(a) arr = a.dup n = arr.length for i in 0..n - 1 j = n - 1 while j > i if arr[j-1][1] > arr[j][1] arr[j-1],arr[j] = arr[j],arr[j-1] end j -= 1 end end arr end def selection_sort(arr) a = arr.dup for i in 0..(a.length - 1) min = i for j in i ..(...
[["-", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6]]
4
245
2
# ALDS1_2_C Stable Sort n = gets.chomp.to_i a = gets.chomp.split(" ") def bubbleSort(c, n) a = c.dup (0..n-1).each do |i| (n-1).downto(i) do |j| if a[j][1].to_i < a[j-1][1].to_i a[j], a[j-1] = a[j-1], a[j] end end end return a end def selectionSort(c, n) a = c.dup (0..n-1).each ...
# ALDS1_2_C Stable Sort n = gets.chomp.to_i a = gets.chomp.split(" ") def bubbleSort(c, n) a = c.dup (0..n-1).each do |i| (n-1).downto(i+1) do |j| if a[j][1].to_i < a[j-1][1].to_i a[j], a[j-1] = a[j-1], a[j] end end end return a end def selectionSort(c, n) a = c.dup (0..n-1).eac...
[["+", 8, 736, 0, 652, 3, 4, 0, 738, 17, 72], ["+", 8, 736, 0, 652, 3, 4, 0, 738, 12, 612], ["-", 75, 95, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 75, 95, 0, 652, 3, 4, 0, 557, 0, 6]]
4
253
4
size = STDIN.gets.to_i c = STDIN.gets.split b = c.dup size.times do |i| (size-1).downto(i) do |j| if b[j][1] < b[j-1][1] b[j], b[j-1] = b[j-1], b[j] end end end puts b.join(' ') def stable?(a1, a2) h1 = Hash.new{|h, k| h[k] = []} h2 = Hash.new{|h, k| h[k] = []} a1.each...
size = STDIN.gets.to_i c = STDIN.gets.split b = c.dup size.times do |i| (size-1).downto(i+1) do |j| if b[j][1] < b[j-1][1] b[j], b[j-1] = b[j-1], b[j] end end end puts b.join(' ') def stable?(a1, a2) h1 = Hash.new{|h, k| h[k] = []} h2 = Hash.new{|h, k| h[k] = []} a1.ea...
[["+", 8, 736, 0, 652, 3, 4, 0, 738, 17, 72], ["+", 8, 736, 0, 652, 3, 4, 0, 738, 12, 612]]
4
318
2
class Card attr_accessor :suit, :value def initialize(str) @suit = str[0] @value = str[1].to_i end def to_s "#@suit#@value" end def self.bubble_sort(c) c = c.dup n = c.size 0.upto(n-1){|i| (n-1).downto(i){|j| if c[j].value < c[j-1].value c[j], c[j-1] = c[j-1], c[j] end } } c...
class Card attr_accessor :suit, :value def initialize(str) @suit = str[0] @value = str[1].to_i end def to_s "#@suit#@value" end def self.bubble_sort(c) c = c.dup n = c.size 0.upto(n-1){|i| (n-1).downto(i+1){|j| if c[j].value < c[j-1].value c[j], c[j-1] = c[j-1], c[j] end } } ...
[["+", 8, 734, 0, 652, 3, 4, 0, 738, 17, 72], ["+", 8, 734, 0, 652, 3, 4, 0, 738, 12, 612], ["-", 0, 493, 0, 662, 31, 761, 0, 776, 0, 48], ["-", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["-", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6]]
4
271
6
def bubbleSort c, n for i in 0...n for j in (i...n).to_a.reverse if c[j][1] < c[j - 1][1] temp = c[j] c[j] = c[j - 1] c[j - 1] = temp end end end end def selectionSort c, n for i in 0...n minj = i for j ...
def bubbleSort c, n for i in 1...n for j in (i...n).to_a.reverse if c[j][1] < c[j - 1][1] temp = c[j] c[j] = c[j - 1] c[j - 1] = temp end end end end def selectionSort c, n for i in 0...n minj = i for j...
[["-", 8, 736, 0, 88, 51, 267, 0, 475, 756, 612], ["+", 8, 736, 0, 88, 51, 267, 0, 475, 756, 612]]
4
265
2
def b_sort(ca) c = ca.dup s = 0 c.sort_by{|i| [i[1], s += 1]} end def s_sort(ca) c = ca.dup c.size.times do |i| m = i i.upto(c.size - 1) do |j| if c[j][1] < c[m][1] m = j end end c[m], c[i] = c[i], c[m] end c end gets a = gets.split.map do |e| e =~ /(\w)(\d+)/ [$1...
def b_sort(ca) c = ca.dup s = 0 c.sort_by{|i| [i[1], s += 1]} end def s_sort(ca) c = ca.dup c.size.times do |i| m = i i.upto(c.size - 1) do |j| if c[j][1] < c[m][1] m = j end end c[m], c[i] = c[i], c[m] end c end gets a = gets.split.map do |e| e =~ /(\w)(\d+)/ [$1...
[["-", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 44], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6]]
4
203
5
def b_sort(ca) c = ca.dup s = 0 c.sort_by{|i| [i[1], s += 1]} end def s_sort(ca) c = ca.dup c.size.times do |i| m = i i.upto(c.size - 1) do |j| if c[j][1] < c[m][1] m = j end end c[m], c[i] = c[m], c[i] end c end gets a = gets.split.map! do |e| e =~ /(\w)(\d+)/ [$...
def b_sort(ca) c = ca.dup s = 0 c.sort_by{|i| [i[1], s += 1]} end def s_sort(ca) c = ca.dup c.size.times do |i| m = i i.upto(c.size - 1) do |j| if c[j][1] < c[m][1] m = j end end c[m], c[i] = c[i], c[m] end c end gets a = gets.split.map do |e| e =~ /(\w)(\d+)/ [$1...
[["-", 8, 736, 0, 662, 12, 762, 0, 742, 0, 22], ["+", 8, 736, 0, 662, 12, 762, 0, 742, 0, 22], ["-", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]]
4
196
6
n = gets.chomp.to_i arr1 = gets.chomp.split(' ') arr2 = [] (0...n).each do |i| arr1[i] = arr1[i].split('') arr1[i][1] = arr1[i][1].to_i arr2[i] = arr1[i] end def is_same?(arr1, arr2, n) (0...n).each do |i| if arr1[i] != arr2[i] return false end end return true end def bubble_sort(arr, n) ...
n = gets.chomp.to_i arr1 = gets.chomp.split(' ') arr2 = [] (0...n).each do |i| arr1[i] = arr1[i].split('') arr1[i][1] = arr1[i][1].to_i arr2[i] = arr1[i] end def is_same?(arr1, arr2, n) (0...n).each do |i| if arr1[i] != arr2[i] return false end end return true end def bubble_sort(arr, n) ...
[["-", 75, 95, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 75, 95, 0, 652, 3, 4, 0, 557, 0, 6]]
4
384
2
n = gets arr = gets.chomp.split arro = arr.clone arr0 = arr.clone arr1 = arr.clone def bubble_sort(arr) count = 0 arr.length.times do |i| j = arr.length - 1 while j >= i+1 if(arr[j-1][1] > arr[j][1]) tmp = arr[j-1] arr[j-1] = arr[j] arr[j] = tmp end j -= 1 end ...
n = gets arr = gets.chomp.split arro = arr.clone arr0 = arr.clone arr1 = arr.clone def bubble_sort(arr) count = 0 arr.length.times do |i| j = arr.length - 1 while j >= i+1 if(arr[j-1][1] > arr[j][1]) tmp = arr[j-1] arr[j-1] = arr[j] arr[j] = tmp end j -= 1 end ...
[["-", 8, 736, 0, 751, 15, 739, 0, 738, 17, 60], ["+", 8, 736, 0, 751, 15, 739, 0, 738, 17, 79]]
4
271
2
def bubble_sort(array, n) n.times do |i| (n - 1).downto(i + 1) do |j| if array[j].num < array[j - 1].num array[j], array[j - 1] = array[j - 1], array[j] end end end array end def selection_sort(array, n) n.times do |i| minj = i i.upto(n - 1) do |j| minj = j if array[j]...
def bubble_sort(array, n) n.times do |i| (n - 1).downto(i + 1) do |j| if array[j].num < array[j - 1].num array[j], array[j - 1] = array[j - 1], array[j] end end end array end def selection_sort(array, n) n.times do |i| minj = i i.upto(n - 1) do |j| minj = j if array[j]...
[["-", 36, 36, 36, 36, 0, 493, 0, 735, 141, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 735, 141, 22], ["-", 196, 737, 8, 736, 0, 751, 15, 738, 17, 60], ["+", 196, 737, 8, 736, 0, 751, 15, 738, 17, 79], ["-", 0, 493, 0, 735, 8, 736, 0, 38, 0, 38], ["-", 36, 36, 0, 493, 0, 121, 15, 652, 735, 22], ["+", 36, 36, 0, 493, 0, 121,...
4
310
7
#! /usr/local/bin/python3 # coding: utf-8 def swap(c, i, j): t = c[i] c[i] = c[j] c[j] = t def bubble_sort(cs, f): c = cs[:] for i in range(len(c) - 1): for j in range(len(c) - 1, i - 1, -1): if f(c[j - 1]) > f(c[j]): swap(c, j - 1, j) # print(i, j, ...
#! /usr/local/bin/python3 # coding: utf-8 def swap(c, i, j): t = c[i] c[i] = c[j] c[j] = t def bubble_sort(cs, f): c = cs[:] for i in range(len(c) - 1): for j in range(len(c) - 1, i, -1): if f(c[j - 1]) > f(c[j]): swap(c, j - 1, j) # print(i, j, c) ...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
380
2
N = int(input()) C1 = list(input().split()) C2 = C1[:] def get_card_suit(card): return card[:1] def get_card_value(card): return card[1:] def bubble_sort(card): r_exists = True while r_exists == True: r_exists = False i = N - 1 while i >= 1: if get_card_value...
N = int(input()) C1 = list(input().split()) C2 = C1[:] def get_card_suit(card): return card[:1] def get_card_value(card): return card[1:] def bubble_sort(card): r_exists = True while r_exists == True: r_exists = False i = N - 1 while i >= 1: if get_card_value...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
310
2
_, cards = input(), input().split() def bubble_sort(array): A = array[:] for i in range(len(A)): for j in range(1, len(A) - i): if int(A[j - 1][1]) > int(A[j][1]): A[j], A[j - 1] = A[j - 1], A[j] return A def selection_sort(array): A = array[:] for i in range(le...
_, cards = input(), input().split() def bubble_sort(array): A = array[:] for i in range(len(A)): for j in range(1, len(A) - i): if int(A[j - 1][1]) > int(A[j][1]): A[j], A[j - 1] = A[j - 1], A[j] return A def selection_sort(array): A = array[:] for i in range(le...
[["-", 8, 196, 0, 37, 0, 41, 0, 557, 0, 6], ["+", 8, 196, 0, 37, 0, 41, 0, 557, 0, 6]]
5
352
2
def bubble_sort(a, n): for i in range(0,n): for j in range(n-1,i-1,-1): if a[j][1] < a[j-1][1]: a[j], a[j-1] = a[j-1], a[j] return a def selection_sort(b, n): for i in range(0,n): minj = i for j in range(i, n): if b[j][1] < b[minj][1]: minj = j b[i], b[minj] = b[minj],...
def bubble_sort(a, n): for i in range(0,n): for j in range(n-1,i,-1): if a[j][1] < a[j-1][1]: a[j], a[j-1] = a[j-1], a[j] return a def selection_sort(b, n): for i in range(0,n): minj = i for j in range(i, n): if b[j][1] < b[minj][1]: minj = j b[i], b[minj] = b[minj], b...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
262
2
n = int(input()) *s1, = input().split() s2 = s1[:] def bubbleSort(s): flag = True while flag: flag = False for i in range(n-1): if int(s[i][1]) > int(s[i+1][1]): s[i],s[i+1] = s[i+1],s[i] flag = True return s def selectionSort(s): for i in ra...
n = int(input()) *s1, = input().split() s2 = s1[:] def bubbleSort(s): flag = True while flag: flag = False for i in range(n-1): if int(s[i][1]) > int(s[i+1][1]): s[i],s[i+1] = s[i+1],s[i] flag = True return s def selectionSort(s): for i in ra...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
232
2
n = int(input()) a = [i for i in input().split()] a2 = a.copy() for i in range(n): for j in reversed(range(i, n)): if a[j][1] < a[j-1][1]: a[j], a[j-1] = a[j-1], a[j] for s in range(n): minj = s for t in range(s+1, n): if a2[t][1] < a2[minj][1]: minj = t if a2[s]...
n = int(input()) a = [i for i in input().split()] a2 = a.copy() for i in range(n): for j in reversed(range(i+1, n)): if a[j][1] < a[j-1][1]: a[j], a[j-1] = a[j-1], a[j] for s in range(n): minj = s for t in range(s+1, n): if a2[t][1] < a2[minj][1]: minj = t if a2[...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
201
2
import copy def bubble_sort(a): ba = copy.copy(a) flag = True for i in range(0, n): if not flag: break flag = False for j in range(n-1, 0, -1): if int(ba[j][1]) < int(ba[j-1][1]): ba[j], ba[j-1] = ba[j-1], ba[j] flag = True ...
import copy def bubble_sort(a): ba = copy.copy(a) flag = True for i in range(0, n): if not flag: break flag = False for j in range(n-1, 0, -1): if int(ba[j][1]) < int(ba[j-1][1]): ba[j], ba[j-1] = ba[j-1], ba[j] flag = True ...
[["-", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["+", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6]]
5
313
2
def show(array): for i in range(len(array)): if (i+1) >= len(array): print(array[i]) else: print(array[i], end=' ') def bubble_sort(c, n): for i in range(0, n): for j in range(n-1, i, -1): if c[j][1:] < c[j-1][1:]: c[j], c[j-1] = c[j-...
def show(array): for i in range(len(array)): if (i+1) >= len(array): print(array[i]) else: print(array[i], end=' ') def bubble_sort(c, n): for i in range(0, n): for j in range(n-1, i, -1): if c[j][1:] < c[j-1][1:]: c[j], c[j-1] = c[j-...
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
299
4
import copy def bubble(N, A): for i in range(N - 1): for j in reversed(range(1, N)): if A[j - 1][1] > A[j][1]: tmp = A[j] A[j] = A[j - 1] A[j - 1] = tmp def select(N, A): for i in range(N): min = i for j in range(i, N): ...
import copy def bubble(N, A): for i in range(N - 1): for j in reversed(range(1, N)): if A[j - 1][1] > A[j][1]: tmp = A[j] A[j] = A[j - 1] A[j - 1] = tmp def select(N, A): for i in range(N): min = i for j in range(i, N): ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79]]
5
274
2
n = int(input()) c = input().split() cb = c[:] for i in range(n): for j in range(n-1,i,-1): if cb[j][1] < cb[j-1][1]: cb[j-1],cb[j] = cb[j],cb[j-1] print(*cb) print('Stable') cs = c[:] for i in range(n): m = min(range(i,n), key=lambda j: cs[j][1]) if i != m: cs[i],cs[m] = cs[m],cs[i] print(*cs) print(('' if...
n = int(input()) c = input().split() cb = c[:] for i in range(n): for j in range(n-1,i,-1): if cb[j][1] < cb[j-1][1]: cb[j-1],cb[j] = cb[j],cb[j-1] print(*cb) print('Stable') cs = c[:] for i in range(n): m = min(range(i,n), key=lambda j: cs[j][1]) if i != m: cs[i],cs[m] = cs[m],cs[i] print(*cs) print('Stabl...
[["-", 0, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6], ["-", 0, 657, 31, 23, 0, 41, 0, 557, 0, 654], ["-", 0, 657, 31, 23, 0, 41, 0, 557, 0, 6], ["-", 0, 652, 3, 4, 0, 657, 31, 23, 0, 25], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 657, 12, 557, 0, 654], ["-", 0, 6...
5
185
9