Submission #2079371
Source Code Expand
#include <iostream> #include <cstdio> #include <vector> #include <map> #include <string> #include <utility> #include <algorithm> #include <functional> #include <climits> #include <math.h> #include <iomanip> #include <fstream> #include <random> using namespace std; bool ff[50][50]={}; int tmp; int tmpx,tmpy; int pix[8][10000][1000],piy[8][10000][1000]; int pic[1000]={}; int f[50][50]={}; int tmpf[50][50]={}; int tx[8],ty[8]={}; int tc=0; int cnt=0; long long score[1000]={}; int st=1; void pi(int n,int x,int y){ if(n==0){pic[cnt]++;st=1; for(int i=0;i<8;++i){ st=st*f[pix[i][pic[cnt]][cnt]][piy[i][pic[cnt]][cnt]]; } score[cnt]+=st; return;} tmp=-1; if(x>=0&&x<50&&y-1>=0&&y-1<50){if(ff[x][y-1]==0&&tmp<f[x][y-1]){tmp=f[x][y-1];tmpx=x;tmpy=y-1;}} if(x>=0&&x<50&&y+1>=0&&y+1<50){if(ff[x][y+1]==0&&tmp<f[x][y+1]){tmp=f[x][y+1];tmpx=x;tmpy=y+1;}} if(x-1>=0&&x-1<50&&y>=0&&y<50){if(ff[x-1][y]==0&&tmp<f[x-1][y]){tmp=f[x-1][y];tmpx=x-1;tmpy=y;}} if(x+1>=0&&x+1<50&&y>=0&&y<50){if(ff[x+1][y]==0&&tmp<f[x+1][y]){tmp=f[x+1][y];tmpx=x+1;tmpy=y;}} if(tmp<0||tmpx<0||tmpx>50||tmpy<0||tmpy>50){ for(int i=0;i<tc;++i){ f[tx[7-i]][ty[7-i]]=0; } tc=0; return;} ff[tmpx][tmpy]=1; tx[n-1]=tmpx; ty[n-1]=tmpy; tc++; pix[n-1][pic[cnt]][cnt]=tmpx; piy[n-1][pic[cnt]][cnt]=tmpy; pi(n-1,tmpx,tmpy); return; } int main() { //cin.tie(0); //ios::sync_with_stdio(false); std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); int h,w,k; cin >> h >> w >> k; string s; char c; int u,v; for(int i=0;i<50;++i){ cin>>s; //cout<<s<<endl; for(int j=0;j<50;++j){ c=s[j]; f[i][j]=c-'0'; } } for(int l=0;l<1000;++l){ /*for(int i=0;i<50;++i){ for(int j=0;j<50;++j){ if(ff[i][j]==0&&f[i][j]!=0){tc++;ff[i][j]=1;tx[7]=i;ty[7]=j;pix[7][pic[cnt]][cnt]=i;piy[7][pic[cnt]][cnt]=j;pi(7,i,j);} } }*/ for(int m=0;m<8000;++m){ u=rand()%50;v=rand()%50; if(ff[u][v]==0&&f[u][v]!=0){tc++;ff[u][v]=1;tx[7]=u;ty[7]=v;pix[7][pic[cnt]][cnt]=u;piy[7][pic[cnt]][cnt]=v;pi(7,u,v);} } cnt++; } st=0;for(int i=0;i<1000;++i){if(score[i]>score[st]){st=i;}} cout<<pic[st]<<endl; for(int i=0;i<pic[st];++i){ for(int j=0;j<8;++j){ cout<<pix[j][i][st]+1<<" "<<piy[j][i][st]+1<<endl; } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Pieces |
User | bono_bono |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2618 Byte |
Status | AC |
Exec Time | 168 ms |
Memory | 4352 KB |
Judge Result
Set Name | test_01 | test_02 | test_03 | test_04 | test_05 | test_06 | test_07 | test_08 | test_09 | test_10 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | 0 / 1343058 | ||||||||||||||||||||
Status |
|
|
|
|
|
|
|
|
|
|
Set Name | Test Cases |
---|---|
test_01 | subtask_01_01.txt |
test_02 | subtask_01_02.txt |
test_03 | subtask_01_03.txt |
test_04 | subtask_01_04.txt |
test_05 | subtask_01_05.txt |
test_06 | subtask_01_06.txt |
test_07 | subtask_01_07.txt |
test_08 | subtask_01_08.txt |
test_09 | subtask_01_09.txt |
test_10 | subtask_01_10.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask_01_01.txt | AC | 165 ms | 4352 KB |
subtask_01_02.txt | AC | 165 ms | 4352 KB |
subtask_01_03.txt | AC | 165 ms | 4352 KB |
subtask_01_04.txt | AC | 165 ms | 4352 KB |
subtask_01_05.txt | AC | 165 ms | 4352 KB |
subtask_01_06.txt | AC | 165 ms | 4352 KB |
subtask_01_07.txt | AC | 168 ms | 4352 KB |
subtask_01_08.txt | AC | 165 ms | 4352 KB |
subtask_01_09.txt | AC | 165 ms | 4352 KB |
subtask_01_10.txt | AC | 165 ms | 4352 KB |