#include<bits/stdc++.h> using namespace std; #define LL long long #define debug(x) cerr<<#x<<" = "<<x #define sp <<" " #define el <<endl #define fgx cerr<<" ---------------------- "<<endl #define uint unsigned int #define ULL unsigned long long #define DB double #define LDB long double #define pii pair<int,int> #define mpt make_pair #define pb push_back #define fr first #define sc second #define M 1000020//Size #define INF 1000000000 #define INFLL 1000000000000000000 inline int read(){ int nm=0,fh=1; char c=getchar(); for(;!isdigit(c);c=getchar()) if(c=='-') fh=-1; for(;isdigit(c);c=getchar()) nm=nm*10+c-'0'; return nm*fh; } #define mod 1000000007//About inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);} inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);} inline int mul(LL x,LL y){return x*y%mod;} inline void upd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);} inline void dec(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);} inline int qpow(int x,LL sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;} int n,ans[M],tp; class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param n int整型 节点个数 * @param u int整型vector * @param v int整型vector * @return int整型 */ int oddnumber(int n, int m, vector<int>& l, vector<int>& r) { // write code here for(int i=1;i<=m;i++) ans[l[i-1]]++,--ans[r[i-1]+1]; for(int i=1;i<=n;i++) ans[i]+=ans[i-1]; for(int i=1;i<=n;i++) ans[i]+=m; int res=0; for(int i=1;i<=n;i++) if(ans[i]&1) res++; return res; } }t;
全部评论
(15) 回帖