제출 #124638

#제출 시각아이디문제언어결과실행 시간메모리
124638deinfreundCATS (NOI14_cats)C++14
8 / 25
1553 ms262148 KiB
#include <bits/stdc++.h> using namespace std; bool reversed[2]; vector<int> stacks[2]; void push(int s, int v){ s--; if (v < 0){ reversed[s] = !reversed[s]; cout << "alarm" << 0/0 << endl; }else{ //cout << "pushing " << v << endl; stacks[s].push_back(v ^ reversed[s]); } } int peek(int s){ s--; if (stacks[s].empty()) return reversed[s]; return stacks[s][stacks[s].size() - 1] ^ reversed[s]; } int pop(int s){ int v = peek(s); s--; if (stacks[s].empty()) return reversed[s]; stacks[s].pop_back(); return v; } int calc(int X, int L, int N){ stacks[0].clear(); stacks[1].clear(); reversed[0] = 0; reversed[1] = 0; int COUNTER = X; while (COUNTER > 0){ push(2, pop(1)); //Push the top element of S1 onto S2 reversed[0] = !reversed[0]; if (peek(2) > L){ COUNTER = COUNTER - 1; if( COUNTER == 0) { return peek(2); } } else{ //cout << stacks[1].size() << endl; push(1, 2*N + peek(2)); push(1, 2*N + peek(2)); pop(2); pop(2); //cout << stacks[1].size() << endl; } } } int calc2(int X, int L, int N){ } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int Q; cin >> Q; for (int q = 0; q< Q; q++){ int x,l,n; cin >>x >>l>> n; cout << calc(x,l,n) << endl; } }

컴파일 시 표준 에러 (stderr) 메시지

cats.cpp: In function 'void push(int, int)':
cats.cpp:12:25: warning: division by zero [-Wdiv-by-zero]
     cout << "alarm" << 0/0 << endl;
                        ~^~
cats.cpp: In function 'int calc2(int, int, int)':
cats.cpp:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
cats.cpp: In function 'int calc(int, int, int)':
cats.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...