# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
406407 |
2021-05-17T14:40:05 Z |
Fidisk |
Lasers (NOI19_lasers) |
C++14 |
|
3 ms |
464 KB |
#include <bits/stdc++.h>
using namespace std;
#define oo 1e15
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
typedef pair<pair<long long,long long>,pair<long long,long long>> pllll;
typedef pair<pair<long long,long long>,bool> pllb;
const ll base=361;
const ll mod=998244353;
const ld eps=1e-5;
const ll maxn=1e9+9;
ll n,m,sum,pre,i,j,k,a[500009],cnt,sl[500009],last,res;
vector<pll> q;
void update(ll l,ll r,ll gt) {
q.push_back({l,gt});
q.push_back({r+1,-gt});
}
ll calc(ll l,ll r) {
return r-l+1;
}
int main(){
IO;
#ifndef ONLINE_JUDGE
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
#else
#endif
last=1;
cin>>m>>n;
for (i=1;i<=n;i++) {
cin>>k;
sum=0;
pre=0;
for (j=1;j<=k;j++) {
cin>>a[j];
sum+=a[j];
}
update(1,m-sum,i);
for (j=1;j<=k;j++) {
pre+=a[j];
sum-=a[j];
update(pre+1,m-sum,i);
}
}
sort(q.begin(),q.end());
for (i=0;i<q.size();i++) {
//cout<<q[i].fi<<' '<<q[i].se<<'\n';
if (q[i].se>0) {
if (sl[q[i].se]==0) {
cnt++;
}
sl[q[i].se]++;
}
else {
sl[-q[i].se]--;
if (sl[-q[i].se]==0) {
cnt--;
}
}
if (i+1<q.size()&&q[i+1].fi!=q[i].fi) {
if (cnt==n) {
res+=calc(last,q[i+1].fi-1);
// cout<<"! "<<last<<' '<<q[i+1].fi-1<<'\n';
}
last=q[i+1].fi;
}
}
if (cnt==n) {
res+=calc(last,m);
//cout<<"! "<<last<<' '<<m<<'\n';
}
//cout<<res<<'\n';
cout<<m-res<<'\n';
}
Compilation message
lasers.cpp: In function 'int main()':
lasers.cpp:65:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for (i=0;i<q.size();i++) {
| ~^~~~~~~~~
lasers.cpp:79:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | if (i+1<q.size()&&q[i+1].fi!=q[i].fi) {
| ~~~^~~~~~~~~
lasers.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | freopen("test.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lasers.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | freopen("test.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |