When codeforces first opened, how did it get so popular?
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
When codeforces first opened, how did it get so popular?
I am having difficulty solving a problem on a different coding website. The problem goes like this:
The m × n rectangular grid is a graph whose vertices correspond to the points in the plane with x-coordinates being integers in the range 0, … , n-1 and y-coordinates being integers in the range 0, … , m-1, and two vertices are joined by an edge whenever the corresponding points are at unit distance apart. For example, a 4 × 6 rectangular grid is shown in Figure 1. The grid has n vertices appearing in each of m rows and m vertices in each of n columns. The vertex in row i and column j is denoted by (i, j), where 0 ≤ i ≤ m — 1 and 0 ≤ j ≤ n — 1.
If we add an edge joining two vertices (i, 0) and (i, n-1) of the m × n rectangular grid for every row i ∈ {0, … , m-1} and moreover, add an edge between two vertices (0, j) and (m-1, j) for every column j ∈ {0, … , n-1}, then each row forms a cycle of length n and each column forms a cycle of length m, as illustrated in Figure 2. The resulting graph is often called an m × n toroidal grid, because it can be drawn on a torus without edge crossings.
Given an m × n toroidal grid, you are to write a program to find a cycle that visits every vertex exactly once. Here, the required cycle may be represented as a sequence, (v1, v2, … , vmn), of mn distinct vertices of the graph such that vk and vk+1 are adjacent for all k ∈ {1, … , mn-1} and moreover, vmn and v1 are adjacent.
I got a compile error my code:
#include<stdio.h>
int main() {
int t;
scanf("%d", &t);
while(t--){
int r, c;
scanf("%d %d", &r, &c);
printf("1\n");
for(int i=0; i=1; j--){
printf("(%d,%d)\n", i, j);
}
}else{
for(int j=1; j=1; i--){
printf("(%d,0)\n", i, 0);
}
}
}
What was wrong?
Is it often for the Judge Queue to go wrong?
I'm afraid oyu8201 is cheating, his code:#include <bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<int, int> ii;
const int N = int(1e6);
int col[N]; int to[N], ant[N], adj[N], z;
void dfs(int u) { fre(i, u) { if(col[to[i]] == -1) { col[to[i]] = col[u] ^ 1; dfs(to[i]); } } } int main() { ios::sync_with_stdio(false);cin.tie(NULL);
memset(col, -1, sizeof col); memset(adj, -1, sizeof adj); z = 0; int n; cin >> n; int a, b; vector<ii> p; fr(i, 0, n) { cin >> a >> b; --a, --b; add_edge(a, b); add_edge(b, a); p.push_back({a, b}); } fr(i, 0, 2 * n) { add_edge(i, i + 1); add_edge(i + 1, i); ++i; } fr(i, 0, 2 * n) { if(col[i] == -1) { col[i] = 0; dfs(i); } } fr(i, 0, n) { cout << col[p[i].first] + 1 << ' ' << col[p[i].second] + 1 << endl; } return 0;
}
my code: #include <bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<int, int> ii;
const int N = int(1e6);
int col[N]; int to[N], ant[N], adj[N], z;
void dfs(int u) { fre(i, u) { if(col[to[i]] == -1) { col[to[i]] = col[u] ^ 1; dfs(to[i]); } } } int main() { ios::sync_with_stdio(false);cin.tie(NULL);
memset(col, -1, sizeof col); memset(adj, -1, sizeof adj); z = 0; int n; cin >> n; int a, b; vector<ii> p; fr(i, 0, n) { cin >> a >> b; --a, --b; add_edge(a, b); add_edge(b, a); p.push_back({a, b}); } fr(i, 0, 2 * n) { add_edge(i, i + 1); add_edge(i + 1, i); ++i; } fr(i, 0, 2 * n) { if(col[i] == -1) { col[i] = 0; dfs(i); } } fr(i, 0, n) { cout << col[p[i].first] + 1 << ' ' << col[p[i].second] + 1 << endl; } return 0;
}
Name |
---|