傳送門
題目:
①所有塊之間能夠相互到達,即使一個連通圖
②所有塊有偶數個鄰居
③規定有n個塊有4個鄰居
每組測驗給定一個n,問你怎么構造一個圖,
思路:水題,我們先構造好一個邊長為2的矩形,然后我們給該矩形右下角添加三個塊就能表達一個“有四個鄰居”的塊,
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <queue> 5 #include <string> 6 #include <vector> 7 #include <cmath> 8 #include <stack> 9 #include <map> 10 11 using namespace std; 12 13 #define ll long long 14 #define pb push_back 15 #define fi first 16 #define se second 17 18 const int N = 2e6 + 10; 19 20 21 void solve() 22 { 23 int n; 24 cin >> n; 25 int sum = 7 + (n - 1) * 3; 26 printf("%d\n", sum); 27 printf("%d %d\n%d %d\n",0,0,1,0); 28 printf("%d %d\n%d %d\n",0,1,1,1); 29 int x = 2, y = 2; 30 for(int i = 1; i <= n; ++i){ 31 printf("%d %d\n%d %d\n%d %d\n",x,y,x-1,y,x,y-1); 32 x += 1; y += 1; 33 } 34 } 35 36 int main() 37 { 38 // ios::sync_with_stdio(false); 39 // cin.tie(0); 40 // cout.tie(0); 41 42 solve(); 43 44 return 0; 45 }
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/10642.html
標籤:其他
上一篇:0106. Construct Binary Tree from Inorder and Postorder Traversal (M)
