QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506359 | #6422. Evil Coordinate | Foedere0 | Compile Error | / | / | C++23 | 3.7kb | 2024-08-05 16:54:36 | 2024-08-05 16:54:36 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#define int long long
//#define endl '\n'
using namespace std;
typedef pair<int,int> PII;
const int N=200200;
int n;
int x,y;
string s;
int o=0,p=0;
map<char,int> m;
void solve(){
m.clear();
o=0,p=0;
cin>>x>>y>>s;
string ans;
ans.clear();
if(x==0&&y==0){
cout<<"Impossible"<<endl;
return;
}
for(int i=0;i<s.size();i++){
if(s[i]=='L') o--;
if(s[i]=='R') o++;
if(s[i]=='U') p++;
if(s[i]=='D') p--;
m[s[i]]++;
}
if(o==x&&p==y){
cout<<"Impossible"<<endl;
return;
}
if(x!=0&&y!=0){
if(x!=o){
while(m['L']){
ans+='L';
m['L']--;
}
while(m['R']){
ans+='R';
m['R']--;
}
while(m['U']) ans+='U',m['U']--;
while(m['D']) ans+='D',m['D']--;
}
else{
while(m['D']){
ans+='D';
m['D']--;
}
while(m['U']){
ans+='U';
m['U']--;
}
while(m['L']) ans+='L',m['L']--;
while(m['R']) ans+='R',m['R']--;
}
cout<<ans<<endl;
return;
}
if(x==0){
int yy=0;
bool st=0;
if(o!=0){
while(m['L']){
ans+='L';
m['L']--;
}
while(m['R']) ans+='R', m['R']--;
while(m['U']) ans+='U', m['U']--;
while(m['D']) ans+='D', m['D']--;
}
else{
if(m['L']) ans+='L',m['L']--;
else if(m['R']) ans+='R',m['R']--;
else if(!m['L']&&!m['R']) st=1;
if(y>=0){
yy=0;
while(m['D']){
ans+='D';
m['D']--;
yy--;
}
while(m['U']){
ans+='U';
yy++;
if(yy==y&&st==1){
cout<<"Impossible"<<endl;
return;
}
m['U']--;
}
}
else{
yy=0;
while(m['U']){
ans+='U';
m['U']--;
yy++;
}
while(m['D']){
ans+='D';
yy--;
if(yy==y&&st==1){
cout<<"Impossible"<<endl;
return;
}
m['D']--;
}
}
while(m['L']) ans+='L', m['L']--;
while(m['R']) ans+='R', m['R']--;
while(m['U']) ans+='U', m['U']--;
while(m['D']) ans+='D', m['D']--;
}
}
else if(y==0){
int xx=0;
bool st=0;
if(p!=0){
xx=0
while(m['U']){
ans+='U';
m['U']--;
}
//cout<<"nmsl"<<endl;
while(m['D']) ans+='D', m['D']--;
while(m['L']) ans+='L', m['L']--;
while(m['R']) ans+='R', m['R']--;
}
else{
xx=0
if(m['U']) ans+='U',m['U']--;
else if(m['D']) ans+='D',m['D']--;
else if(!m['U']&&!m['D']) st=1;
//cout<<ans<<endl;
if(x>=0){
while(m['L']){
ans+='L';
xx--;
m['L']--;
}
while(m['R']){
ans+='R';
xx++;
if(xx==x&&st){
cout<<"Impossible"<<endl;
return;
}
m['R']--;
}
}
else{
while(m['R']){
ans+='R';
xx++;
m['R']--;
}
while(m['L']){
ans+='L';
xx--;
if(xx==x&&st){
cout<<"Impossible"<<endl;
return;
}
m['L']--;
}
}
while(m['U']) ans+='U', m['U']--;
while(m['D']) ans+='D', m['D']--;
}
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T=1;
cin>>T;
while(T--){
solve();
}
return 0;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:128:29: error: expected ‘;’ before ‘while’ 128 | xx=0 | ^ | ; 129 | while(m['U']){ | ~~~~~ answer.code:139:29: error: expected ‘;’ before ‘if’ 139 | xx=0 | ^ | ; 140 | if(m['U']) ans+='U',m['U']--; | ~~ answer.code:141:21: error: expected ‘}’ before ‘else’ 141 | else if(m['D']) ans+='D',m['D']--; | ^~~~ answer.code:138:21: note: to match this ‘{’ 138 | else{ | ^ answer.code:141:21: error: expected ‘}’ before ‘else’ 141 | else if(m['D']) ans+='D',m['D']--; | ^~~~ answer.code:124:22: note: to match this ‘{’ 124 | else if(y==0){ | ^ answer.code:142:47: error: ‘st’ was not declared in this scope; did you mean ‘std’? 142 | else if(!m['U']&&!m['D']) st=1; | ^~ | std answer.code:147:29: error: ‘xx’ was not declared in this scope; did you mean ‘x’? 147 | xx--; | ^~ | x answer.code:152:33: error: ‘xx’ was not declared in this scope; did you mean ‘x’? 152 | xx++; | ^~ | x answer.code:153:39: error: ‘st’ was not declared in this scope; did you mean ‘std’? 153 | if(xx==x&&st){ | ^~ | std answer.code:163:29: error: ‘xx’ was not declared in this scope; did you mean ‘x’? 163 | xx++; | ^~ | x answer.code:168:29: error: ‘xx’ was not declared in this scope; did you mean ‘x’? 168 | xx--; | ^~ | x answer.code:169:35: error: ‘st’ was not declared in this scope; did you mean ‘std’? 169 | if(xx==x&&st){ | ^~ | std answer.code: At global scope: answer.code:179:9: error: expected declaration before ‘}’ token 179 | } | ^ answer.code:180:9: error: ‘cout’ does not name a type 180 | cout<<ans<<endl; | ^~~~ answer.code:181:1: error: expected declaration before ‘}’ token 181 | } | ^