When codeforces first opened, how did it get so popular?
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | adamant | 152 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 144 |
| 5 | errorgorn | 141 |
| 6 | cry | 139 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 9 | TheScrasse | 134 |
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;}
| Название |
|---|


