#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
#define ff first
#define ss second
#define fip(a,b) for(ll i = a ; i<b;i++)
#define fjp(a,b) for(ll j = a ; j<b;j++)
#define fp(k,a,b) for(ll k = a ; k<b;k++)
#define fin(a,b) for(ll i = a;i>=b;i--)
#define fjn(a,b) for(ll j = a;j>=b;j--)
#define fn(k,a,b) for(ll k = a;k>=b;k--)
#define fx(k) for(auto x : k)
#define ordered_set <ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define totalone(x) _builtin_popcountll(x)
#define frontzero(x) _builtin_clzll(x)
#define backzero(x) _builtin_ctzll(x)
#define nli "\n";
#ifndef ONLINE_JUDGE
#define debug(x) cerr<<#x<<" "<<printn(x)<<nli;
#else
#define debug(x)
#endif
void printn(ll x){cerr<<x<<" ";};
void printn(int x){cerr<<x<<" ";};
void printn(double x){cerr<<x<<" ";};
void printn(bool x){cerr<<x<<" ";};
void printn(char x){cerr<<x<<" ";};
void printn(string x){cerr<<x<<" ";};
template<class T> void printn(set<T> s);
template<class T> void printn(vector<T> s);
template<class T,class V> void printn(pair<T, V> s);
template<class T,class V> void printn(map<T, V> s);
template<class T> void printn(set<T> s){cerr<<"{ ";fx(s){printn(x);cerr<<",";};cerr<<"}";}
template<class T> void print(vector<T> s){cerr<<"[ ";fx(s){print(x);cerr<<",";};cerr<<"]";}
template<class T,class V> void print(pair<T,V> s){cerr<<"( ";print(s.ff);cerr<<",";print(s.ss);cerr<<")";}
template<class T,class V> void print(map<T,V> s){cerr<<"[ ";fx(s){print(x);cerr<<",";};cerr<<"]";}
const ll mx = 1e5 + 5;
const ll mod = 1e9 + 7;
ll n,m,sum,ans,res,cnt,tp,tp2,tptp;
ll sr,de;
ll tnc[mx];
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("input1.txt","r",stdin);
// freopen("output1.txt","w",stdout);
// freopen("error1.txt","w",stderr);
cin>>n>>m;
fip(0,n-1){
cin>>sr>>de;
}
ans = 0;
fip(0,m){
cin>>tp;
vi a(tp);
fjp(0,tp){
cin>>tp2;
tnc[tp2]++;
}
cnt = 0;
fip(2,n+1){
if(!tnc[i])cnt++;
else cnt += tnc[i];
}
if(n&1){
cout<<0<<nli;
continue;
}
ans = 0;
fip(2,n+1){
if(!tnc[i])ans++;
else if(tnc[i]&1)
ans += (tnc[i] + 1);
else
ans += (tnc[i]+2);
}
cout<<ans<<nli;
}
cerr<<"time elapsed: "<<setprecision(6)<<1000.0*clock()/CLOCKS_PER_SEC<<"ms"<<nli;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1058 ms |
972 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1047 ms |
1712 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |