CSES - Aalto Competitive Programming 2024 - wk10 - Homework - Results
Submission details
Task:Line Intersections
Sender:eyong002
Submission time:2024-11-11 18:43:01 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:10:18: error: 'N' was not declared in this scope
   10 |     scanf("%d", &N);
      |                  ^
input/code.cpp:20:16: error: expected ';' before '}' token
   20 |             h++
      |                ^
      |                ;
   21 |         }
      |         ~       
input/code.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d %d %d %d", &a, &b, &c, &d);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Code

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxN = 1e5+1;
const int maxX = 1e6+5;
const int SIZE = 2*maxX;

int main(){
    scanf("%d", &N);
    int h, v;
    h = v = 0;
    for(int i = 0, a, b, c, d; i < N; i++){
        scanf("%d %d %d %d", &a, &b, &c, &d);
        if(a == c){
            // Vertical
            v++;
        } else {
            // Horizontal
            h++
        }
    }
    cout << h * v;
}