Submission #1304123
Source Code Expand
#include <iostream> #include<sstream> #include<vector> #include<iterator> #include<algorithm> #include<queue> using namespace std; #define YES "YES" #define NO "NO" int main(void) { int N; cin >> N; vector<int> NG(3, 0); for(auto it=NG.begin(); it!=NG.end(); it++) cin >> *it; if(find(NG.begin(), NG.end(), N) != NG.end()) { cout << NO << endl; return 0; } queue<int> que1, que2; queue<int> *prev, *next; prev = &que1; next = &que2; // seed next->push(N); vector<bool> table(301, true); table[N] = false; for(auto it=NG.begin(); it!=NG.end(); it++) table[*it] = false; int cnt = 0; bool success = false; const int movement[3] = {-1, -2, -3}; while(next->empty() != true) { cnt++; swap(prev, next); while(prev->empty() != true) { int pre = prev->front(); prev->pop(); for(auto it=begin(movement); it!=end(movement); it++) { int state = pre + *it; if(state < 0) continue; else if(table[state] == false) continue; if(state == 0) { success = true; swap(*prev, queue<int>()); swap(*next, queue<int>()); break; } next->push(state); table[state] = false; } } if(cnt == 100) break; } if(success == true && cnt <= 100) cout << YES << endl; else cout << NO << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 123引き算 |
User | callman |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1396 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:64:30: error: no matching function for call to ‘swap(std::queue<int>&, std::queue<int>)’ swap(*prev, queue<int>()); ^ In file included from /usr/include/c++/5/bits/stl_pair.h:59:0, from /usr/include/c++/5/bits/stl_algobase.h:64, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/ios:40, from /usr/include/c++/5/ostream:38, from /usr/include/c++/5/iostream:39, from ./Main.cpp:1: /usr/include/c++/5/bits/move.h:176:5: note: candidate: void std::swap(_Tp&, _Tp&) [with _Tp = std::queue<int>] <near match> swap(_Tp& __a, _Tp& __b) ^ /usr/include/c++/5/bits/move.h:176:5: note: conversion of argument 2 would be ill-formed: ./Main.cpp:64:30: error: invalid initialization of non-const reference of type ‘std::queue<int>&’ from an rvalue of type ‘std::queue<int>’ swap(*prev, queue<int>()); ...