Submission #1135959

#TimeUsernameProblemLanguageResultExecution timeMemory
1135959agrim_09Lightning Rod (NOI18_lightningrod)C++20
Compilation error
0 ms0 KiB

using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define double lld
typedef long long ll;


bool cmp(pair<int,int>p,pair<int,int>q){
    if(p.first!=q.first){
        return p.first<q.first;
    }
    return (p.second>q.second);
}

signed main(){
    fastio; //judge();
    int n; cin >> n;
    vector<pair<int,int>>a(n);
    for(int i = 0;i<n;i++) cin >> a[i].first >> a[i].second;

    vector<pair<int,int>>alpha(n);
    for(int i = 0;i<n;i++){
        alpha[i].first = a[i].first - a[i].second;
        alpha[i].second = a[i].first + a[i].second;
    }
    
    sort(alpha.begin(),alpha.end(),cmp);
    int count = 1, close = alpha[0].second;
    for(int i = 1;i<n;i++){
        if(alpha[i].second>close){
            count++; close = alpha[i].second;
        }
    }
    cout << count;
}

Compilation message (stderr)

Main.cpp:9:10: error: 'pair' was not declared in this scope
    9 | bool cmp(pair<int,int>p,pair<int,int>q){
      |          ^~~~
Main.cpp:1:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
  +++ |+#include <utility>
    1 | 
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:9:15: note: in expansion of macro 'int'
    9 | bool cmp(pair<int,int>p,pair<int,int>q){
      |               ^~~
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:9:19: note: in expansion of macro 'int'
    9 | bool cmp(pair<int,int>p,pair<int,int>q){
      |                   ^~~
Main.cpp:9:25: error: 'pair' was not declared in this scope
    9 | bool cmp(pair<int,int>p,pair<int,int>q){
      |                         ^~~~
Main.cpp:9:25: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:9:30: note: in expansion of macro 'int'
    9 | bool cmp(pair<int,int>p,pair<int,int>q){
      |                              ^~~
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:9:34: note: in expansion of macro 'int'
    9 | bool cmp(pair<int,int>p,pair<int,int>q){
      |                                  ^~~
Main.cpp:9:39: error: expression list treated as compound expression in initializer [-fpermissive]
    9 | bool cmp(pair<int,int>p,pair<int,int>q){
      |                                       ^
Main.cpp: In function 'int main()':
Main.cpp:3:16: error: 'ios_base' has not been declared
    3 | #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
      |                ^~~~~~~~
Main.cpp:17:5: note: in expansion of macro 'fastio'
   17 |     fastio; //judge();
      |     ^~~~~~
Main.cpp:3:50: error: 'cin' was not declared in this scope
    3 | #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
      |                                                  ^~~
Main.cpp:17:5: note: in expansion of macro 'fastio'
   17 |     fastio; //judge();
      |     ^~~~~~
Main.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | 
Main.cpp:3:62: error: 'cout' was not declared in this scope
    3 | #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
      |                                                              ^~~~
Main.cpp:17:5: note: in expansion of macro 'fastio'
   17 |     fastio; //judge();
      |     ^~~~~~
Main.cpp:3:62: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    3 | #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
      |                                                              ^~~~
Main.cpp:17:5: note: in expansion of macro 'fastio'
   17 |     fastio; //judge();
      |     ^~~~~~
Main.cpp:19:12: error: 'pair' was not declared in this scope
   19 |     vector<pair<int,int>>a(n);
      |            ^~~~
Main.cpp:19:12: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
Main.cpp:19:5: error: 'vector' was not declared in this scope
   19 |     vector<pair<int,int>>a(n);
      |     ^~~~~~
Main.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | 
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:19:17: note: in expansion of macro 'int'
   19 |     vector<pair<int,int>>a(n);
      |                 ^~~
Main.cpp:20:35: error: 'a' was not declared in this scope
   20 |     for(int i = 0;i<n;i++) cin >> a[i].first >> a[i].second;
      |                                   ^
Main.cpp:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
Main.cpp:22:17: note: in expansion of macro 'int'
   22 |     vector<pair<int,int>>alpha(n);
      |                 ^~~
Main.cpp:24:9: error: 'alpha' was not declared in this scope
   24 |         alpha[i].first = a[i].first - a[i].second;
      |         ^~~~~
Main.cpp:24:26: error: 'a' was not declared in this scope
   24 |         alpha[i].first = a[i].first - a[i].second;
      |                          ^
Main.cpp:28:10: error: 'alpha' was not declared in this scope
   28 |     sort(alpha.begin(),alpha.end(),cmp);
      |          ^~~~~
Main.cpp:28:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   28 |     sort(alpha.begin(),alpha.end(),cmp);
      |     ^~~~
      |     short