Submission #1482032
Source Code Expand
#include<string> #include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<map> using namespace std; typedef long long int llint; #define mp make_pair #define mt make_tuple #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define fir first #define sec second #define res resize #define ins insert #define era erase const int mod=1000000007; const llint big=1e18+10; const long double pai=3.141592653589793238462643383279502884197; const long double eps=1e-9; template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}} template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}} int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b class in_t{public: int a;in_t(){cin>>a;} operator int() {return a;} }; class lin_t{public: llint a;lin_t(){cin>>a;} operator llint() {return a;} }; class ld_t{public: long double a;ld_t(){cin>>a;} operator long double() {return a;} }; int main(void){ in_t n; string str;cin>>str; //o->SSS,WSW string ans(n+2); for(int ba=0;ba<4;ba++){ if(ba==0){ans[0]='S',ans[1]='S';} if(ba==1){ans[0]='S',ans[1]='W';} if(ba==2){ans[0]='W',ans[1]='S';} if(ba==3){ans[0]='W',ans[1]='W';} for(i=1;i<=n;i++){ int bi=0; if(ans[i-1]=='W'){bi++;} if(ans[i]=='W'){bi++;} if(str[i-1]=='x'){bi++;} if(bi%2==0){ans[i+1]='S';} else{ans[i+1]='W';} } if(!(ans[0]==ans[n]&&ans[1]==ans[n+1])){continue;} ans.pob();ans.pob(); cout<<ans<<endl;return 0; } cout<<"-1"<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | WA_TLE |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1749 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:52:16: error: no matching function for call to ‘std::basic_string<char>::basic_string(int)’ string ans(n+2); ^ In file included from /usr/include/c++/5/string:52:0, from ./Main.cpp:1: /usr/include/c++/5/bits/basic_string.h:3012:9: note: candidate: template<class _InputIterator> std::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&) basic_string(_InputIterator __beg, _InputIterator __end, ^ /usr/include/c++/5/bits/basic_string.h:3012:9: note: template argument deduction/substitution failed: ./Main.cpp:52:16: note: candidate expects 3 arguments, 1 provided string ans(n+2); ^ In file included from /usr/include/c++/5/string:52:0, from ./Main.cpp:1: /usr/include/c++/5/bits/basic_string.h:3002:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = ...