QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#373819 | #2043. Make a Sequence | KKT89 | 100 ✓ | 130ms | 3868kb | C++17 | 1.4kb | 2024-04-02 07:50:07 | 2024-04-02 07:50:07 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
int n,m,p;
int x[400],y[400];
int h[7][7],t[7][7][7];
int dx[]={1,0,0,1,1,0,1,-1,0,1,-1,1,1};
int dy[]={0,1,0,1,0,1,-1,0,1,1,1,-1,1};
int dz[]={0,0,1,0,1,1,0,1,-1,1,1,1,-1};
void putball(int x,int y,int colar){
t[y][x][h[y][x]]=colar;
h[y][x]++;
}
bool judge(int colar){
for(int i=0;i<7;i++){
for(int j=0;j<7;j++){
for(int k=0;k<7;k++){
for(int q=0;q<13;q++){
int cnt=0;
while(1){
int nx=i+dx[q]*cnt,ny=j+dy[q]*cnt,nz=k+dz[q]*cnt;
if(0<=nx&&nx<7&&0<=ny&&ny<7&&0<=nz&&nz<7&&t[nx][ny][nz]==colar){
cnt++;
}else break;
}
if(cnt>=m)return true;
}
}
}
}
return false;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
while(1){
cin >> n >> m >> p;
if(n==0&&m==0&&p==0)break;
for(int i=0;i<p;i++){
cin >> x[i] >> y[i];
x[i]--; y[i]--;
}
for(int i=0;i<7;i++){
for(int j=0;j<7;j++){
h[i][j]=0;
for(int k=0;k<7;k++){
t[i][j][k]=-1;
}
}
}
int t=0;
bool ok=0;
for(int i=0;i<p;i++){
putball(x[i],y[i],t);
if(judge(t)){
if(t==0){
printf("Black %d\n",i+1);
}else{
printf("White %d\n",i+1);
}
ok=1;
break;
}
t^=1;
}
if(!ok){
printf("Draw\n");
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 130ms
memory: 3868kb
input:
3 3 3 1 1 1 1 1 1 3 3 14 1 1 2 2 3 2 3 1 1 3 1 2 1 3 1 3 2 3 3 3 1 2 1 1 3 1 3 1 3 3 5 1 1 1 3 2 1 2 3 3 1 3 3 5 1 1 3 1 1 2 3 2 1 3 3 3 5 1 1 2 2 1 1 2 2 1 1 3 3 5 1 1 3 1 2 2 3 2 3 3 3 3 5 3 1 1 1 2 2 1 2 1 3 3 3 7 1 1 2 1 2 1 3 1 1 1 3 1 3 1 3 3 7 3 1 2 1 2 1 1 1 3 1 1 1 1 1 3 3 7 1 1 1 2 1 2 1 3...
output:
Draw Draw Black 5 Black 5 Black 5 Black 5 Black 5 Black 7 Black 7 Black 7 Black 7 Black 7 Black 7 Black 7 Black 7 Black 7 Black 7 Black 7 Black 7 Black 11 Black 11 Black 11 Black 11 Black 11 Black 11 Black 11 Black 11 Black 11 Black 11 Black 13 Black 13 White 8 Black 11 Black 7 White 22 White 10 Bla...
result:
ok 166 lines