QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#735671 | #9469. Chinese Checkers | Midsummer | WA | 26ms | 3640kb | C++14 | 12.6kb | 2024-11-11 21:12:56 | 2024-11-11 21:12:57 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define inf 0x3f3f3f3f
#define endl '\n'
#define pai acos(-1.0)
using namespace std;
int mapi[25][25];
int vis[25][25];
void init()
{
memset(mapi,-1,sizeof mapi);
for(int i = 1; i <= 17; i++)
{
if(i <= 4)
{
for(int j = 5; j <= 5+i-1; j++)
{
mapi[i][j] = 1;
vis[i][j] = 1;
}
}
else if(i <= 8)
{
for(int j = i-5+1; j <= 4; j++)
{
mapi[i][j] = 6;
vis[i][j] = 6;
}
for(int j = 5; j <= 9+i-5; j++)
{
mapi[i][j] = 0;
}
for(int j = 10+i-5; j <= 13; j++)
{
mapi[i][j] = 4;
vis[i][j] = 4;
}
}
else if(i >= 10 && i <= 13)
{
for(int j = 5; j <= 5+i-10; j++)
{
mapi[i][j] = 3;
vis[i][j] = 3;
}
for(int j = 6+i-10 ; j <= 13; j++)
{
mapi[i][j] = 0;
}
for(int j = 14; j <= 14+i-10; j++)
{
mapi[i][j] = 5;
vis[i][j] = 5;
}
}
else if(i >= 14 && i <= 17)
{
for(int j = 10+i-14; j <= 13; j++)
{
mapi[i][j] = 2;
vis[i][j] = 2;
}
}
for(int j = 5; j <= 13; j++)
{
mapi[9][j] = 0;
}
}
}
bool check(int x,int y,int ops)
{
if((ops == 1 || ops == 2) && (vis[x][y] != 1 && vis[x][y] != 2 && vis[x][y] != 0))
return 0;
if((ops == 3 || ops == 4) && (vis[x][y] != 3 && vis[x][y] != 4 && vis[x][y] != 0))
return 0;
if((ops == 5 || ops == 6) && (vis[x][y] != 5 && vis[x][y] != 6 && vis[x][y] != 0))
return 0;
return 1;
}
struct node
{
int x;
int y;
};
bool cmp(node a,node b)
{
if(a.x != b.x)
return a.x < b.x;
else
return a.y < b.y;
}
void solve()
{
int n;
while(cin >> n)
{
init();
// for(int i = 1; i <= 17; i++)
// {
// for(int j = 1; j <= 17; j++)
// {
// cout << mapi[i][j] << " ";
// }
// cout << endl;
// }
int pltimes = 1;
for(int i = 1; i <= n; i++)
{
int x,y;
string dir;
cin >> x >> y >> dir;
int cnt = y;
for(int j = 1; j <= 17; j++)
{
if(mapi[x][j] != -1)
cnt--;
if(cnt == 0)
{
y = j;
break;
}
}
if(pltimes != mapi[x][y])
{
pltimes++;
continue;
}
pltimes++;
if(pltimes > 6) pltimes -= 6;
int endx = x;
int endy = y;
// cout << endx << " " << endy << " " << dir << endl;
if(dir == "L")
{
int sttimes = 0;
string op1;
string op2;
endy--;
while(mapi[endx][endy] != -1)
{
if(check(endx,endy,mapi[x][y]) == 0) break;
if(mapi[endx][endy] != 0)
{
op1 += '1';
sttimes++;
}
else op1 += '0';
endy--;
}
op2 = op1; reverse(op2.begin(),op2.end());
while(1)
{
if(op1.size() == 0) break;
string ccc;
ccc = op1[op1.size()-1];
if(ccc[0] != '0') sttimes--;
op1.erase(op1.size()-1,op1.size());
op2.erase(0,1);
if(op1 == op2 && ccc[0] == '0' && sttimes != 0) break;
}
if(op1.size() == 0)
{
if(mapi[x][y-1] == 0)
{
mapi[x][y-1] = mapi[x][y];
mapi[x][y] = 0;
}
continue;
}
endy = y-op1.size()-1;
mapi[endx][endy] = mapi[x][y];
mapi[x][y] = 0;
}
else if(dir == "R")
{
int sttimes = 0;
string op1;
string op2;
endy++;
while(mapi[endx][endy] != -1)
{
if(check(endx,endy,mapi[x][y]) == 0) break;
if(mapi[endx][endy] != 0)
{
op1 += '1';
sttimes++;
}
else op1 += '0';
endy++;
}
op2 = op1; reverse(op2.begin(),op2.end());
while(1)
{
if(op1.size() == 0) break;
string ccc;
ccc = op1[op1.size()-1];
op1.erase(op1.size()-1,op1.size());
op2.erase(0,1);
if(op1 == op2 && ccc[0] == '0' && sttimes != 0) break;
}
if(op1.size() == 0)
{
if(mapi[x][y+1] == 0)
{
mapi[x][y+1] = mapi[x][y];
mapi[x][y] = 0;
}
continue;
}
endy = y + op1.size()+1;
mapi[endx][endy] = mapi[x][y];
mapi[x][y] = 0;
}
else if(dir == "UL")
{
int sttimes = 0;
string op1;
string op2;
endx--; endy--;
while(mapi[endx][endy] != -1)
{
if(check(endx,endy,mapi[x][y]) == 0) break;
if(mapi[endx][endy] != 0)
{
op1 += '1';
sttimes++;
}
else op1 += '0';
endx--; endy--;
}
// cout << op1 << endl;
op2 = op1; reverse(op2.begin(),op2.end());
while(1)
{
if(op1.size() == 0) break;
string ccc;
ccc = op1[op1.size()-1];
op1.erase(op1.size()-1,op1.size());
op2.erase(0,1);
if(op1 == op2 && ccc[0] == '0' && sttimes != 0) break;
}
if(op1.size() == 0)
{
if(mapi[x-1][y-1] == 0)
{
mapi[x-1][y-1] = mapi[x][y];
mapi[x][y] = 0;
}
continue;
}
endx = x - op1.size()-1;
endy = y - op1.size()-1;
mapi[endx][endy] = mapi[x][y];
mapi[x][y] = 0;
}
else if(dir == "UR")
{
int sttimes = 0;
string op1;
string op2;
endx--;
while(mapi[endx][endy] != -1)
{
if(check(endx,endy,mapi[x][y]) == 0) break;
if(mapi[endx][endy] != 0)
{
op1 += '1';
sttimes++;
}
else op1 += '0';
endx--;
}
op2 = op1; reverse(op2.begin(),op2.end());
while(1)
{
if(op1.size() == 0) break;
string ccc;
ccc = op1[op1.size()-1];
op1.erase(op1.size()-1,op1.size());
op2.erase(0,1);
if(op1 == op2 && ccc[0] == '0' && sttimes != 0) break;
}
if(op1.size() == 0)
{
if(mapi[x-1][y] == 0)
{
mapi[x-1][y] = mapi[x][y];
mapi[x][y] = 0;
}
continue;
}
endx = x - op1.size()-1;
mapi[endx][endy] = mapi[x][y];
mapi[x][y] = 0;
}
else if(dir == "LL")
{
int sttimes = 0;
string op1;
string op2;
endx++;
while(mapi[endx][endy] != -1)
{
if(check(endx,endy,mapi[x][y]) == 0) break;
if(mapi[endx][endy] != 0)
{
op1 += '1';
sttimes++;
}
else op1 += '0';
endx++;
}
op2 = op1; reverse(op2.begin(),op2.end());
while(1)
{
if(op1.size() == 0) break;
string ccc;
ccc = op1[op1.size()-1];
op1.erase(op1.size()-1,op1.size());
op2.erase(0,1);
if(op1 == op2 && ccc[0] == '0' && sttimes != 0) break;
}
if(op1.size() == 0)
{
if(mapi[x+1][y] == 0)
{
mapi[x+1][y] = mapi[x][y];
mapi[x][y] = 0;
}
continue;
}
endx = x + op1.size()+1;
mapi[endx][endy] = mapi[x][y];
mapi[x][y] = 0;
}
else if(dir == "LR")
{
int sttimes = 0;
string op1;
string op2;
endx++;
endy++;
while(mapi[endx][endy] != -1)
{
if(check(endx,endy,mapi[x][y]) == 0) break;
if(mapi[endx][endy] != 0)
{
op1 += '1';
sttimes++;
}
else op1 += '0';
endx++; endy++;
}
op2 = op1; reverse(op2.begin(),op2.end());
while(1)
{
if(op1.size() == 0) break;
string ccc;
ccc = op1[op1.size()-1];
op1.erase(op1.size()-1,op1.size());
op2.erase(0,1);
if(op1 == op2 && ccc[0] == '0' && sttimes != 0) break;
}
if(op1.size() == 0)
{
if(mapi[x+1][y+1] == 0)
{
mapi[x+1][y+1] = mapi[x][y];
mapi[x][y] = 0;
}
continue;
}
endx = x + op1.size()+1;
endy = y + op1.size()+1;
mapi[endx][endy] = mapi[x][y];
mapi[x][y] = 0;
}
}
vector<node>a[7];
for(int i = 1; i <= 6; i++)
{
for(int j = 1; j <= 17; j++)
{
int tmp = 0;
for(int k = 1; k <= 17; k++)
{
if(mapi[j][k] == -1)
{
tmp++;
}
if(mapi[j][k] == i)
{
a[i].push_back({j,k-tmp});
}
}
}
}
for(int i = 1; i <= 6; i++)
{
sort(a[i].begin(),a[i].end(),cmp);
}
for(int i = 1; i <= 6; i++)
{
for(auto t:a[i])
{
cout << t.x << " " << t.y << " ";
}
cout << endl;
}
}
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t = 1;
// cin>>t;
while(t--)
solve();
}
//cout << fixed << setprecision(5) << num << endl;
// priority_queue<int,vector<int>,less<int>>q;
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
12 1 1 LL 16 1 UL 10 1 R 5 11 L 11 10 L 7 1 LR 2 2 LR 13 5 UL 12 2 R 5 12 L 11 11 L 6 1 LR
output:
2 1 3 1 3 2 3 3 4 1 4 2 4 3 4 4 5 5 6 9 12 4 14 1 14 2 14 3 14 4 15 1 15 2 15 3 16 2 17 1 10 2 11 1 11 2 12 1 12 3 12 5 13 1 13 2 13 3 13 4 5 7 5 9 5 10 5 13 6 10 6 11 6 12 7 10 7 11 8 10 10 10 11 7 11 9 12 10 12 11 12 12 13 10 13 11 13 12 13 13 5 1 5 2 5 3 5 4 6 2 6 3 7 1 7 2 8 1 11 3
result:
ok 6 lines
Test #2:
score: -100
Wrong Answer
time: 26ms
memory: 3608kb
input:
39 4 1 LR 14 1 UR 13 4 R 6 12 L 13 10 UL 6 2 R 3 1 LL 16 1 UR 13 1 R 6 9 UL 12 12 L 6 4 L 2 1 LL 13 6 R 13 8 UR 6 11 R 10 10 LL 5 2 R 9 1 R 16 2 LL 10 1 UL 5 13 LL 13 13 UL 5 5 R 3 2 UL 17 1 UR 11 8 UL 8 10 LL 13 12 L 6 2 LR 4 2 LL 15 1 LR 11 1 UR 7 11 UL 13 10 UR 8 1 LR 4 4 LR 13 9 UL 13 3 R 39 4 1...
output:
1 1 2 1 2 2 3 2 3 3 4 1 4 2 4 3 4 4 5 6 12 8 13 6 14 2 14 3 14 4 15 1 15 2 15 3 16 2 17 1 10 1 11 1 11 2 12 1 12 2 12 3 13 2 13 3 13 4 13 8 5 9 5 10 5 11 5 12 5 13 6 10 6 11 7 10 7 11 8 10 6 6 10 10 11 10 11 11 12 9 12 10 12 11 13 11 13 12 13 13 5 1 5 2 5 3 5 4 6 1 6 3 6 7 7 1 7 2 8 1 2 1 2 2 ...
result:
wrong answer 1st lines differ - expected: '1 1 2 1 2 2 3 1 3 3 4 3 5 6 8 9 9 2 10 2', found: '1 1 2 1 2 2 3 2 3 3 4 1 4 2 4 3 4 4 5 6 '