When codeforces first opened, how did it get so popular?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
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;
}
Название |
---|