A simple question
It may not be easy to read
Is to give n * m matrix, let you find k paths can fill the Matrix
Each path must have a minimum of 2 grids, and the grids on the path must be adjacent.
It's better to understand the meaning of the question. Just be greedy.
Before the K-1 step each take 2 lattice, the last finish the rest of the grid can be
The Code is as follows:
#include <cstdio>#include <iostream>#include <algorithm>#define MAXN 100010#define ll long longusing namespace std;int n, m, k, cnt, col, row;int x[MAXN], y[MAXN];int main(void) { while(cin >> n >> m >> k) { cnt = 1; x[1] = 1; row = 1; y[1] = 1; col = 1; while(cnt <= n*m) { cnt++; if((col==m&&row%2) || (col==1&&row%2==0)) { row++; x[cnt] = row; y[cnt] = col; } else { if(row % 2) { col++; } else { col--; } x[cnt] = row; y[cnt] = col; } } /* cout << cnt << endl; for(int i=1; i<cnt; ++i) { cout << x[i] << " " << y[i] << endl; } */ int j = 1; for(int i=1; i<k; ++i) { cout << "2 " << x[j] << " " << y[j] << " "; ++j; cout << x[j] << " " << y[j] << endl; ++j; } cout << cnt-j << " "; for(int i=j; i<cnt-1; ++i) { cout << x[i] << " " << y[i] << " "; } cout << x[cnt-1] << " " << y[cnt-1] << endl; } return 0;}
Now again, I think codeforces's 3rd question is not that difficult.
I want to locate myself again later