...
 
Commits (8)
TARGET = sim
OBJS = $(CPPS:.cpp=.o)
CPPS = $(wildcard *.cpp)
CXX = g++
CXXFLAGS = -O3 -DSOFTWARE
all: main.cpp io.c solver.cpp router/router.cpp
g++ -o solve solver.cpp main.cpp io.c router/router.cpp -std=c++11
all: $(TARGET)
o: main.o io.o solver.o
g++ -o solve main.o io.o solver.o
$(TARGET): $(OBJS)
$(CXX) -o $@ $(OBJS)
main.o: main.cpp
g++ -c main.cpp
clean:
rm *.o
rm $(TARGET)
io.o: io.c
g++ -c io.c
solver.o: solver.cpp
g++ -c solver.cpp -std=c++11
TARGET = sim
OBJS = $(CPPS:.cpp=.o)
CPPS = $(wildcard *.cpp)
CXX = g++
CXXFLAGS = -O3 -DSOFTWARE
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) -o $@ $(OBJS)
clean:
rm *.o
rm $(TARGET)
makeで実行ファイルsolverができます.
MAKEFILE
g++ -o solve solver.cpp main.cpp io.c router/router.cpp -std=c++11
./solver < QUESTIONFILEで実行され解答のみを出力します.
必要ヘッダ
<limits.h>
<stdio.h>
<vector>
<algorithm>
"solver.h"
"io.h"
"router/router.hpp"
\ No newline at end of file
# 2019/08/26 追記
配線失敗時にボードを出力しないように変更しました
# 実行方法
```
cd nszw-solver
make
./solve < QUESTIONFILE
```
or
```
cd nszw-solver
g++ -o solve solver.cpp main.cpp io.c router/router.cpp -std=c++11
./solve < QUESTIONFILE
```
# 必要ヘッダ
* limits.h
* stdio.h
* vector
* algorithm
* "solver.h"
* "io.h"
* "router/router.hpp"
# 必要ファイル
* router/router.cpp
* io.c
* main.cpp
* solver.cpp
# 制約
* ブロックの横総数が72より小さい
* ブロックの縦総数が72より小さい
# アルゴリズム
* ブロックを縦,横に写像
* 写像をもとに配置,配線
* 配線に沿って縮小
* 空白を埋めるように縮小
* 解答
This diff is collapsed.
......@@ -101,17 +101,11 @@ void read_problem(void){
void print_answer(void){
printf("\n --ANSWER-- \n"); //comment out this row
int i,j;
h=H;
w=W;
printf("SIZE %dX%d\n",w,h);
for(i=0;i<h;i++){
for(j=0;j<w;j++){
if(board_data[j][i]!=-1){
printf("%d",board_data[j][i]);
}else{
printf("*");
}
if(j==h-1)
printf("%3d",board_data[j][i]);
if(j==w-1)
printf("\n");
else
printf(",");
......
......@@ -5,8 +5,8 @@
#define MAXBLOCK 5184 // 72*72
#define MAXLINE 2592 // 72*72/2
#define MAXW 72
#define MAXH 72
#define MAXW 120
#define MAXH 120
extern short int W, H; // (問題で設定された) 盤面サイズ上限
......
......@@ -2,13 +2,16 @@
/* Last Change: 2019/05/21 (Tue) 14:44:03. */
#include"io.h"
#include"solver.h"
#include <stdio.h>
int main(void){
read_problem();
H=20;
W=20;
solver();
if(solver()){
printf("success!");
print_answer();
}else{
printf("failed...");
}
return 0;
}
......
......@@ -73,7 +73,7 @@ int router(short int size_x, short int size_y, short int line_num, short int boa
lfsr_random_init(seed);
// Step 1
cout << "1st routing ..." << endl;
//cout << "1st routing ..." << endl;
for(i = 0; i < line_num; i++) {
if(adjacents[i]) continue;
#ifdef PRINT_SEARCH
......@@ -90,7 +90,7 @@ int router(short int size_x, short int size_y, short int line_num, short int boa
ap_uint<1> overlap_checks[MAX_CELLS];
// Step 2
cout << "rip-up routing ..." << endl;
//cout << "rip-up routing ..." << endl;
short int last_target = -1;
ap_uint<16> round;
for(round = 1; round <= ROUND_LIMIT; round++) {
......
......@@ -11,8 +11,8 @@
using namespace std;
#define ROUND_LIMIT 32768 // Max=65534(=2^16-2)
#define PRINT_BOARD
#define ROUND_LIMIT 8192//4096//32768 // Max=65534(=2^16-2)
//#define PRINT_BOARD
//#define PRINT_SEARCH // for router debug
#define MAX_LINES 256
......
No preview for this file type
This diff is collapsed.
......@@ -5,6 +5,6 @@
#define MAXSIZE 128
void solver(void);
int solver(void);
#endif // _SOLVER_H_
No preview for this file type