When codeforces first opened, how did it get so popular?
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 156 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 135 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
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 |
|---|


