Description
作業規則
• 程式作業必須自己從無到有完成
• 禁止參考同學的程式
• 禁止直接複製網路上有的程式
• 跟團隊合作、找資料能力無關。
• 跟跑馬拉松不可以搭車、代跑、抄捷徑一樣。
• 禁止提供作業程式給別的同學
• 包括公布在網路、LMS上
• 一旦多份作業間有部份雷同就都沒有分數
• 不論原因 (抄襲、被抄襲、被偷看、參考網路…)
• 包括所有上傳到Online Judge或LMS的半成品
• 保管自己程式的責任
• 特別注意:設定工作站資料夾的權限
• 我無法驗證「同學偷看我的程式我也沒辦法」這類的理由
1
作業規則
• 有問題請在 LMS 討論區發問
• 請勿貼出程式發問
• 原則上,不接受私下 email 詢問助教、老師
• 助教、老師不幫學生 debug 作業
Magic Square Checker
https://acm.cs.nthu.edu.tw/problem/12153/
Definition: “good” magic squares
• The sum of integers in each row, column, and
diagonal is equal
2 7 6
9 5 1
4 3 8
2 2 2
2 2 2
2 2 2
8 11 14 1
13 2 7 12
3 16 9 6
10 5 4 15
sum = 15 sum = 6 sum = 34
Definition: “fixable” magic squares
• Exactly one swap results in a good magic square
8 11 14 1
(13) 2 7 12
3 16 (9) 6
10 5 4 15
sum = 34
8 11 14 1
9 2 7 12
3 16 13 6
10 5 4 15
“Fixable” magic square
Input
3
7
164 173 182 135 144 151 162
172 181 141 143 152 161 163
180 140 142 153 160 169 171
139 148 150 159 168 170 179
147 149 158 167 176 178 138
155 157 166 175 177 137 146
156 165 174 183 136 145 154
9
152 163 174 129 106 117 128 139 150
162 173 184 114 116 127 138 149 151
172 183 113 115 126 137 148 159 161
182 112 123 125 136 147 158 160 171
111 122 124 135 146 157 168 170 181
121 132 134 145 156 167 169 109 110
131 133 144 155 166 177 179 180 120
141 143 154 165 176 178 108 119 130
142 153 164 175 186 107 118 185 140
9
149 160 171 182 103 114 125 136 147
159 170 181 111 113 124 135 146 148
169 180 110 112 123 134 145 156 158
179 109 120 122 133 144 155 157 168
108 119 121 132 143 154 165 167 178
118 129 131 142 153 164 166 177 107
128 130 141 152 163 174 176 106 117
138 140 151 162 173 175 105 116 127
139 150 161 172 183 104 115 126 137
number of squares (1~25)
width and height (3~25)
a square to check
each entry can be 1~999
Output
fixable 1113
164 173 182 135 144 (153) 162
172 181 141 143 152 161 163
180 140 142 (151) 160 169 171
139 148 150 159 168 170 179
147 149 158 167 176 178 138
155 157 166 175 177 137 146
156 165 174 183 136 145 154
bad
good 1287
Result of the first square
sum of each row, col, and diagonal
If the square is fixable, fix it.
Parenthesize the swapped entries.
Result of the second square
Result of the third square
sum of each row, col, and diagonal 6 characters
Reviews
There are no reviews yet.