#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
const int MAX_N = 1000000;
bitset<2 * MAX_N + 7> dr; // z gory na dol
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
vector<int> hori;
for(int i = 0; i < n; i++) {
int a, w, t; cin >> a >> w >> t;
if(a == 1) {
int idx = MAX_N - (w - 1) + t;
// cout << idx << "\n";
dr[idx] = 1;
}
else {
hori.push_back(MAX_N - (w - 1) + t);
}
}
// cout << "\n";
// for(int i: hori) cout << i << " ";
// cout << "\n";
int ans = 0;
for(int i = 0; i < hori.size(); i++) {
if(dr[hori[i]]) ans++;
}
cout << ans << "\n";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <iostream> #include <bitset> #include <vector> using namespace std; const int MAX_N = 1000000; bitset<2 * MAX_N + 7> dr; // z gory na dol int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> hori; for(int i = 0; i < n; i++) { int a, w, t; cin >> a >> w >> t; if(a == 1) { int idx = MAX_N - (w - 1) + t; // cout << idx << "\n"; dr[idx] = 1; } else { hori.push_back(MAX_N - (w - 1) + t); } } // cout << "\n"; // for(int i: hori) cout << i << " "; // cout << "\n"; int ans = 0; for(int i = 0; i < hori.size(); i++) { if(dr[hori[i]]) ans++; } cout << ans << "\n"; return 0; } |
English