-
Notifications
You must be signed in to change notification settings - Fork 5
/
441C.cpp
74 lines (66 loc) · 1.4 KB
/
441C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//21171_somesh || asomesh999
//AC
#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;
vector<vi> visited;
int X[] = {0, 0, 1, -1};
int Y[] = {1, -1, 0, 0};
int n, m;
vector<pii> arr;
bool check(int x, int y) {
if(x >= 0 && x < n && y >= 0 && y < m) {
return true;
}
return false;
}
void dfs(int x, int y) {
visited[x][y] = 1;
arr.push_back({x, y});
for(int i = 0; i < 4; i++) {
int dx = x + X[i], dy = Y[i] + y;
if(check(dx, dy)) {
if(!visited[dx][dy]) {
dfs(dx, dy);
}
}
}
}
int main()
{
io
#ifdef SOMU
clock_t startTime = clock();
freopen("input.txt","r",stdin);
#endif
int k;
cin >> n >> m >> k;
visited.resize(n, vi(m));
dfs(0, 0);
int size = (n * m) / k;
int j = 0;
fr(i, 0, k - 1) {
cout << size << ' ';
j = i * size;
for(; j < size + i * size; j++){
cout << arr[j].first + 1 << ' ' << arr[j].second + 1 << ' ';
}
cout << '\n';
}
cout << m * n - j << ' ';
fr(i, j, arr.size()) {
cout << arr[i].first + 1 << ' ' << arr[i].second + 1 << ' ';
}
#ifdef SOMU
cout << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
#endif
return 0;
}