C. Even Picture(構造)

題目傳送門

題意: 在一個可以無限空間擴展的網格紙中,我們可以對一些點進行染色,要求是每個被染色的點周圍四個點中,只能有偶數個點被染色,現在要求你輸出,恰好有n個點周圍四個點都被染色的一種方案(其他點周圍是兩個)。

思路: 考慮下面這種構造方法,每多一個環就多一個符合條件的點。

代碼:

#include<bits/stdc++.h>
#define endl '\n'
#define null NULL
#define ls p<<1
#define rs p<<1|1
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define int long long
#define pii pair<int,int>
#define ull unsigned long long
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ct cerr<<"Time elapsed:"<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
char *fs,*ft,buf[1<<20];
#define gc() (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<20,stdin),fs==ft))?0:*fs++;
inline int read(){int x=0,f=1;char ch=gc();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
return x*f;}
using namespace std;
const int N=2e5+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const double eps=1e-7;
const double PI=acos(-1);
signed main()
{
    int n;
    cin>>n;
    vector<pii>v;
    v.pb(mp(0,0));v.pb(mp(0,1));v.pb(mp(0,2));v.pb(mp(1,0));
    v.pb(mp(1,2));v.pb(mp(2,0));v.pb(mp(2,1));v.pb(mp(2,2));
    for(int i=1;i<=n;i++)
        for(int j=1;j<=7;j++)
            v.pb(mp(v[j].fi+2*i,v[j].se+2*i));
    cout<<v.size()<<endl;
    for(auto i:v)
        cout<<i.fi<<' '<<i.se<<endl;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章