답안 #1007849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007849 2024-06-25T14:59:25 Z christinelynn Lasers (NOI19_lasers) C++17
100 / 100
152 ms 16292 KB
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned long long int ull;
const ll md = 1e9+7;
const int ukr = 5e5+10;
int read() {
    int ketek = 0; bool ne=0;
    register char c = getchar();
    while(c == ' ' or c =='\n') c =getchar();
    if(c=='-'){ne = 1; c = getchar();}
    while(c >= '0' and c <='9') { ketek = (ketek<<3)+(ketek<<1)+c-'0'; c = getchar();}
    if(ne) ketek*=-1;
    return ketek;
}   
void print(int x) {
    if (x < 0) {putchar('-');x = -x;}
    int len = 0, buf[10];
    if (x == 0) {putchar('0');return;}
    while (x > 0) {buf[len++] = x % 10; x/=10;}
    while (len > 0) {putchar('0' + buf[--len]);}
}
void File_Work(){
  freopen("test.in","r",stdin);
  freopen("test.out","w",stdout);
}
int n, m, a, b, c, d, id;
struct babi{
    ll x, y;
    bool operator < (const babi &other) const{
        if(x == other.x){
            return y < other.y;
        }
        return x < other.x;
    }
};
struct babis{
    ll x, y;
};
ll gcd(ll a, ll b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}
ll pgkt(ll rnx, ll rny){
    if(rny == 0) return 1;
    ll nwrn = pgkt(rnx, rny/2);
    if(rny%2){
        return (((nwrn*nwrn)%md)*rnx)%md;
    }else{
        return (nwrn*nwrn)%md;
    }
}
vector<babi> v;
string s;
ll ar[ukr];
set<pair<ll,ll>> st;
void solve(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a;
        ll tot = 0, tet = 0;
        for(int j = 1; j <= a; j++){
            cin >> ar[j];
            tot += ar[j];
        }
        for(int j = 1; j <= a; j++){
            ll l = tet+1, r = n-tot+ar[j]; 
            if(r-ar[j]+1 <= l+ar[j]-1)st.insert({r-ar[j]+1, l+ar[j]-1});
            tet += ar[j]; tot -= ar[j];
        }
    }
    ll l = 0, r = -1, ans = 0;
    for(auto i : st){
        if(r < i.first){
            ans += r-l+1;
            l = i.first;
            r = i.second;
        }else{
            r = max(r, i.second);
        }
    }
    ans += r-l+1;
    cout << ans << "\n";
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
  int t =1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        //cout << "Case " << i << ": ";
        solve();
    }
}

Compilation message

lasers.cpp: In function 'int read()':
lasers.cpp:10:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   10 |     register char c = getchar();
      |                   ^
lasers.cpp: In function 'void File_Work()':
lasers.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   freopen("test.in","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
lasers.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   freopen("test.out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 50 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 143 ms 13400 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 13140 KB Output is correct
2 Correct 11 ms 4444 KB Output is correct
3 Correct 5 ms 3420 KB Output is correct
4 Correct 40 ms 14264 KB Output is correct
5 Correct 21 ms 6748 KB Output is correct
6 Correct 24 ms 5980 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 28 ms 6292 KB Output is correct
9 Correct 31 ms 11100 KB Output is correct
10 Correct 50 ms 16292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 412 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 13140 KB Output is correct
2 Correct 11 ms 4444 KB Output is correct
3 Correct 5 ms 3420 KB Output is correct
4 Correct 40 ms 14264 KB Output is correct
5 Correct 21 ms 6748 KB Output is correct
6 Correct 24 ms 5980 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 28 ms 6292 KB Output is correct
9 Correct 31 ms 11100 KB Output is correct
10 Correct 50 ms 16292 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 412 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 135 ms 12116 KB Output is correct
22 Correct 30 ms 4444 KB Output is correct
23 Correct 11 ms 5724 KB Output is correct
24 Correct 51 ms 13700 KB Output is correct
25 Correct 127 ms 12116 KB Output is correct
26 Correct 49 ms 8784 KB Output is correct
27 Correct 18 ms 3672 KB Output is correct
28 Correct 139 ms 12080 KB Output is correct
29 Correct 128 ms 12264 KB Output is correct
30 Correct 30 ms 10072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 50 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 143 ms 13400 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 45 ms 13140 KB Output is correct
22 Correct 11 ms 4444 KB Output is correct
23 Correct 5 ms 3420 KB Output is correct
24 Correct 40 ms 14264 KB Output is correct
25 Correct 21 ms 6748 KB Output is correct
26 Correct 24 ms 5980 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 28 ms 6292 KB Output is correct
29 Correct 31 ms 11100 KB Output is correct
30 Correct 50 ms 16292 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 412 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 135 ms 12116 KB Output is correct
42 Correct 30 ms 4444 KB Output is correct
43 Correct 11 ms 5724 KB Output is correct
44 Correct 51 ms 13700 KB Output is correct
45 Correct 127 ms 12116 KB Output is correct
46 Correct 49 ms 8784 KB Output is correct
47 Correct 18 ms 3672 KB Output is correct
48 Correct 139 ms 12080 KB Output is correct
49 Correct 128 ms 12264 KB Output is correct
50 Correct 30 ms 10072 KB Output is correct
51 Correct 19 ms 6740 KB Output is correct
52 Correct 152 ms 15200 KB Output is correct
53 Correct 134 ms 15184 KB Output is correct
54 Correct 31 ms 5456 KB Output is correct
55 Correct 85 ms 12624 KB Output is correct
56 Correct 62 ms 12368 KB Output is correct
57 Correct 59 ms 9296 KB Output is correct
58 Correct 143 ms 15844 KB Output is correct
59 Correct 42 ms 7248 KB Output is correct
60 Correct 51 ms 8272 KB Output is correct