This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define loop(i,n) for (ll i = 0; i < n; i++)
#define ll long long
#define INF 1e9+5
#define MAXN 300007
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
int main(){
ll l,r,k,x,maxi=0;
cin>>l>>r;
vector<vector<ll>>row(r);
loop(i,r){
cin>>x;
maxi=max(maxi,x);
loop(j,x){
cin>>k;
row[i].pb(k);
}
}
if(maxi==1){//só há um por linha
ll savedL=INF, savedR=-1;
loop(i,r){
k=row[i][0];
savedR = max(savedR , k);
savedL = min(savedL, l-k-1);
}
k = savedL+1;
savedR=max(savedR,savedL+1);
k+=(l-savedR);
printf("%lld\n",l-k);
}else{
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |