제출 #239132

#제출 시각아이디문제언어결과실행 시간메모리
239132Dynamic_CastLasers (NOI19_lasers)C++14
65 / 100
1101 ms45172 KiB
//#include <bits/stdc++.h> C++11
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <time.h>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <stack>
#include <queue>
#include <climits>
#include <map>
#include <set>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int L, R, X, temp;
    cin >> L >> R;
    vi append;
    vector<vi> wall;
    set<int> blocked;
    int flag, maxx;
    flag = 1;
    maxx = 0;
    for (int i = 0; i < R; i++)
    {
        cin >> X;
        if (X > 1)
        {
            flag = 0;
        }
        cin >> temp;
        maxx = max(maxx, temp);
        append.PB(temp);
        for (int j = 1; j < X; j++)
        {
            cin >> temp;
            maxx = max(maxx, temp);
            append.PB(temp+append[j-1]);
        }
        wall.PB(append);
        append.clear();
        
    }
    if (flag == 1)
    {
        cout << max(2 * maxx - L, 0) << "\n";
    }
    if (flag == 0)
    {
        int f2 = 0;
        int space;
        for (int i = 0; i < R; i++)
        {
            for(int j=0;j<int(wall[i].size());j++){
                if(j==0){
                    space=L-(wall[i][int(wall[i].size())-1]-wall[i][j]);
                    //cout<<"space (for wall "<<j<<" in line "<<i<<") = "<<space<<"\n";
                    for(int k=space-wall[i][j];k<wall[i][j];k++){
                        blocked.insert(k);
                        //cout<<k<<"\n";
                    }
                }
                else{
                    space=L-(wall[i][int(wall[i].size())-1]-wall[i][j])-wall[i][j-1];
                    //cout<<"space (for wall "<<j<<" in line "<<i<<") = "<<space<<"\n";
                    for(int k=wall[i][j-1]+space-(wall[i][j]-wall[i][j-1]);k<wall[i][j];k++){
                        blocked.insert(k);
                        //cout<<k<<"\n";
                    }
                }
            }
        }
        cout << int(blocked.size()) << "\n";
    }
    
}

컴파일 시 표준 에러 (stderr) 메시지

lasers.cpp: In function 'int main()':
lasers.cpp:63:13: warning: unused variable 'f2' [-Wunused-variable]
         int f2 = 0;
             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...