2 条题解

  • 0
    @ 2025-4-14 14:40:25
    ```#include<bits/stdc++.h>
    using namespace std;
    #define int long long
    const int N = 2e5 + 9;
    map<int,int>mp1;
    map<pair<int,int>,int>mp2;
    vector<pair<int,int>> a[N];
    signed main(){
    	int n;cin>>n;
    	for(int i=1;i<=n;i++){
    		int m;cin>>m;
    		for(int j=1;j<=m;j++){
    			int x,y;
    			cin>>x>>y;
    			a[i].push_back({x,y});
    			mp1[x] = max(mp1[x],y);
    			mp2[{x,y}]++;
    		}
    	}
    	int res = 0,f1 = 1;
    	for(int i = 1;i <=n;i++){
    		int f = 0;
    		for(int j = 0;j < a[i].size();j++){
    			if(mp2[a[i][j]]==1 && mp1[a[i][j].first] == a[i][j].second){
    				f = 1;
    			}
    		}
    		if(f == 1) res++;
    		else{
    			res += f1;
    			f1 = 0;
    		}
    		
    	}
    	cout<<res;
    	return 0;
    }
    
    • 0
      @ 2025-4-11 12:16:01
      #include <bits/stdc++.h>
      
      using u32 = unsigned;
      using i64 = long long;
      using u64 = unsigned long long;
      using i128 = __int128;
      
      void solve() {
          int n;
          std::cin >> n;
      
          std::vector<std::vector<std::pair<int, int>>> a(n);
          std::set<std::vector<std::pair<int, int>>> S;
          std::map<int, std::vector<int>> mp;
          for (int i = 0; i < n; i++) {
              int m;
              std::cin >> m;
              for (int j = 0; j < m; j++) {
                  int p, e;
                  std::cin >> p >> e;
                  a[i].emplace_back(p, e);
                  mp[p].emplace_back(e);
              }
          }
      
          for (auto &it: mp) {
              auto &v = it.second;
              std::sort(v.begin(), v.end());
          }
      
          for (const auto &v: a) {
              std::vector<std::pair<int, int>> t;
              for (auto it: v) {
                  int p = it.first, e = it.second;
                  if (mp[p].size() == 1) {
                      t.emplace_back(p, e);
                  } else {
                      if (e < mp[p].back()) {
                          continue;
                      } else {
                          if (mp[p][mp[p].size() - 2] == e) {
                              continue;
                          } else {
                              t.emplace_back(p, e);
                          }
                      }
                  }
              }
              S.insert(t);
          }
          std::cout << S.size() << "\n";
      }
      
      int main() {
          std::ios::sync_with_stdio(false);
          std::cin.tie(nullptr), std::cout.tie(nullptr);
      
          int T = 1;
          // std::cin >> T;
          while (T--) {
              solve();
          }
      
          return 0;
      }
      
      • 1

      信息

      ID
      334
      时间
      1500ms
      内存
      256MiB
      难度
      9
      标签
      (无)
      递交数
      491
      已通过
      33
      上传者