203132026-01-06 12:49:24hunzombiBináris Sakkcpp17Forditási hiba
// NOTE: it is recommended to use this even if you don't understand the following code.

#include <fstream>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

dfs1(int node, vector<bool>& sz) {
    sz[node] = true;
    for (int next : graph[node]) {
        if (!sz[next]) {
            dfs1(next, sz);
        }
    }
}

int main() {
    // uncomment the two following lines if you want to read/write from files
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int r, c, n;
    cin >> r >> c >> n;

    vector<pair<int, int>> nodes;
    vector<vector<int>> graph(n);
    
    vector<int> r(n), c(n);
    for (int i = 0; i < n; ++i) {
        cin >> r[i] >> c[i];
    }
    
    vector<vector<int>> graph(n, vector<int>(0));
    for (int i=0; i < n; i++) {
        int u = r[i], v = c[i];
        for (int j = 0; j < nodes.size(); j++) {
            pair<int, int> node = nodes[j];
            int x = node.first, y = node.second;
            if (u == x || v == y || abs(x - y) == abs(u - v) || x + y == u + v) {
                graph[i].push_back(j);
                graph[j].push_back(i);
            }
        }
        nodes.push_back({u, v});
    }

    long long ans = 0;
    stack<int> st;
    vector<bool> sz(n, false);
    for (int i=0; i < n; i++) {
        if (!sz[i]) {
            dfs1(i, sz);
        }
    }

    return 0;
}
Forditási hiba
open /var/local/lib/isolate/435/box/a.out: no such file or directory
main.cpp:10:1: error: ISO C++ forbids declaration of 'dfs1' with no type [-fpermissive]
   10 | dfs1(int node, vector<bool>& sz) {
      | ^~~~
main.cpp: In function 'int dfs1(int, std::vector<bool>&)':
main.cpp:12:21: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
   12 |     for (int next : graph[node]) {
      |                     ^~~~~
      |                     isgraph
main.cpp:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
main.cpp: In function 'int main()':
main.cpp:33:17: error: conflicting declaration 'std::vector<int> r'
   33 |     vector<int> r(n), c(n);
      |                 ^
main.cpp:27:9: note: previous declaration as 'int r'
   27 |     int r, c, n;
      |         ^
main.cpp:33:23: error: conflicting declaration 'std::vector<int> c'
   33 |     vector<int> r(n), c(n);
      |                       ^
main.cpp:27:12: note: previous declaration as 'int c'
   27 |     int r, c, n;
      |            ^
main.cpp:35:17: error: invalid types 'int[int]' for array subscript
   35 |         cin >> r[i] >> c[i];
      |                 ^
main.cpp:35:25: error: invalid types 'int[int]' for array subscript
   35 |         cin >> r[i] >> c[i];
      |                         ^
main.cpp:38:25: error: redeclaration of 'std::vector<std::vector<int> > graph'
   38 |     vector<vector<int>> graph(n, vector<int>(0));
      |                         ^~~~~
main.cpp:31:25: note: 'std::vector<std::vector<int> > graph' previously declared here
   31 |     vector<vector<int>> graph(n);
      |                         ^~~~~
main.cpp:40:18: error: invalid types 'int[int]' for array subscript
   40 |         int u = r[i], v = c[i];
      |                  ^
main.cpp:44:27: error: 'v' was not declared in this scope
   44 |             if (u == x || v == y || abs(x - y) == abs(u - v) || x + y == u + v) {
      |                           ^
main.cpp:49:29: error: 'v' was not d...