...
 
Commits (8)
TARGET = sim all: main.cpp io.c solver.cpp router/router.cpp
OBJS = $(CPPS:.cpp=.o) g++ -o solve solver.cpp main.cpp io.c router/router.cpp -std=c++11
CPPS = $(wildcard *.cpp)
CXX = g++
CXXFLAGS = -O3 -DSOFTWARE
all: $(TARGET) o: main.o io.o solver.o
g++ -o solve main.o io.o solver.o
$(TARGET): $(OBJS) main.o: main.cpp
$(CXX) -o $@ $(OBJS) g++ -c main.cpp
clean: io.o: io.c
rm *.o g++ -c io.c
rm $(TARGET)
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){ ...@@ -101,17 +101,11 @@ void read_problem(void){
void print_answer(void){ void print_answer(void){
printf("\n --ANSWER-- \n"); //comment out this row printf("\n --ANSWER-- \n"); //comment out this row
int i,j; int i,j;
h=H;
w=W;
printf("SIZE %dX%d\n",w,h); printf("SIZE %dX%d\n",w,h);
for(i=0;i<h;i++){ for(i=0;i<h;i++){
for(j=0;j<w;j++){ for(j=0;j<w;j++){
if(board_data[j][i]!=-1){ printf("%3d",board_data[j][i]);
printf("%d",board_data[j][i]); if(j==w-1)
}else{
printf("*");
}
if(j==h-1)
printf("\n"); printf("\n");
else else
printf(","); printf(",");
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#define MAXBLOCK 5184 // 72*72 #define MAXBLOCK 5184 // 72*72
#define MAXLINE 2592 // 72*72/2 #define MAXLINE 2592 // 72*72/2
#define MAXW 72 #define MAXW 120
#define MAXH 72 #define MAXH 120
extern short int W, H; // (問題で設定された) 盤面サイズ上限 extern short int W, H; // (問題で設定された) 盤面サイズ上限
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
/* Last Change: 2019/05/21 (Tue) 14:44:03. */ /* Last Change: 2019/05/21 (Tue) 14:44:03. */
#include"io.h" #include"io.h"
#include"solver.h" #include"solver.h"
#include <stdio.h>
int main(void){ int main(void){
read_problem(); read_problem();
H=20; if(solver()){
W=20; printf("success!");
solver();
print_answer(); print_answer();
}else{
printf("failed...");
}
return 0; return 0;
} }
......
...@@ -73,7 +73,7 @@ int router(short int size_x, short int size_y, short int line_num, short int boa ...@@ -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); lfsr_random_init(seed);
// Step 1 // Step 1
cout << "1st routing ..." << endl; //cout << "1st routing ..." << endl;
for(i = 0; i < line_num; i++) { for(i = 0; i < line_num; i++) {
if(adjacents[i]) continue; if(adjacents[i]) continue;
#ifdef PRINT_SEARCH #ifdef PRINT_SEARCH
...@@ -90,7 +90,7 @@ int router(short int size_x, short int size_y, short int line_num, short int boa ...@@ -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]; ap_uint<1> overlap_checks[MAX_CELLS];
// Step 2 // Step 2
cout << "rip-up routing ..." << endl; //cout << "rip-up routing ..." << endl;
short int last_target = -1; short int last_target = -1;
ap_uint<16> round; ap_uint<16> round;
for(round = 1; round <= ROUND_LIMIT; round++) { for(round = 1; round <= ROUND_LIMIT; round++) {
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
using namespace std; using namespace std;
#define ROUND_LIMIT 32768 // Max=65534(=2^16-2) #define ROUND_LIMIT 8192//4096//32768 // Max=65534(=2^16-2)
#define PRINT_BOARD //#define PRINT_BOARD
//#define PRINT_SEARCH // for router debug //#define PRINT_SEARCH // for router debug
#define MAX_LINES 256 #define MAX_LINES 256
......
No preview for this file type
This diff is collapsed.
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
#define MAXSIZE 128 #define MAXSIZE 128
void solver(void); int solver(void);
#endif // _SOLVER_H_ #endif // _SOLVER_H_
No preview for this file type