深夜切題 ly與lyon的終極巔峰對決

2021-07-30 23:18:00 字數 2058 閱讀 9322

時間限制:1000ms  記憶體限制:65535k

從前有一天,ly與lyon在討論人工智慧裡面的博弈問題,恰好,他們提到了五子棋。

當然,這裡說的五子棋是指無禁手(不知道什麼是禁手的也不用管了,跟這題沒關係)的五子棋:

黑先下,黑白輪流下,最先在橫豎斜任一方向上形成連續的5個子(或以上)就算贏。

對此,ly和lyon都有自己的一套判斷局勢的演算法,並且根據自己的想法各寫了乙個判斷局況的程式。然而,他們都覺得自己的程式要比對方的優秀,所以,

他們稍作改良,做成了自動決策的對局程式,並拿出來互相pk。目前需要乙個自動判斷勝負的程式,即最先出現5連子的判勝。

第1行輸入兩個數n和m,用空格分開,n為棋盤橫縱座標的最大值,m為步數:

1<=n<=1000,0

輸出首次分出勝負那一步的序號(第一步為1),如果走完了都沒有分出勝負,輸出「baga」。

5 11

3 32 3

2 44 3

4 23 4

1 53 2

5 11 1

1 2

9

一看題,憑我的水平就暴力掃吧。。。打完機腦子裡沒有其他方法(蠢。。。)(run)

//#pragma comment(linker, "/stack:1024000000,1024000000")

#include #include #include //#include #include #include #include #include #include #include //#include #include #include #include using namespace std;

#define mp make_pair

#define pb push_back

#define mst(a,b) memset((a),(b),sizeof(a))

#define test cout<<"*************************"<= (e); i-=(down))

#define rep1(s,n,up) for(int j = (s); j < (n); j+=(up))

#define per1(n,e,down) for(int j = (n); j >= (e); j-=(down))

typedef long long ll;

typedef unsigned long long ull;

typedef pairpii;

typedef vectorvi;

typedef vectorvii;

const int inf = 0x3f3f3f3f;

const ll inf = (1ull << 63) - 1;

const double pi = acos(-1.0);

const int maxn = (1 << 16) + 7;

const ull hashmod = 29050993;

const double esp=1e-6;

#define local

int chessboard[1001][1001],n,m,flag=0;

void checkrow(int i,int j,int step)

void checkcolumn(int i,int j,int step)

void checkxright(int i,int j,int step)

void checkxleft(int i,int j,int step)

int main() {

#ifdef local

freopen("input.txt", "r", stdin);

//freopen("output.txt","w",stdout);

#endif

//ios::sync_with_stdio(0);

mst(chessboard,0);

int i,j,k;

scanf("%d%d",&n,&m);

int step=0;

while(step++

程序的始與終

include linux sched.h struct task struct引數標誌 含義clone files 父子程序共享開啟的檔案 clone fs 父子程序共享檔案系統資訊 clone sighand 父子程序共享訊號處理函式及被阻斷的訊號 clone vm 父子程序共享位址空間 clo...

深夜裡的自我吐槽與自我展望

或許是沉浸在高考完就解放之中還未緩過神來,對於自己的大一上學期對於自己的表現我只能打個d,離開初高中六年的封閉式寄宿學校步入這個自由的大學殿堂我顯然沒能好好安排自己控制自己。選這個專業,我覺得自己以後很輕鬆會變得it大神,什麼軟體 各種牛叉技術都玩的很溜,可目前的我還離得好遠。沒上大學時我對那些大學...

遲到的2023年終總結 責任與能力

其實很早就想寫一篇年終總結了,可礙於最近一直在騎驢找馬,白天工作,晚上面試,週末總結面試的知識點。今天終於放假了,才能夠抽出時間來總結一下自己的2020。受疫情影響,正月初十才回到北京,回到北京後又居家辦公了大概一兩個月,後面又變成了,單雙號去單位辦公,五一過後才基本上就恢復正常工作了。本來是一開始...