제출 #230514

#제출 시각아이디문제언어결과실행 시간메모리
230514topovikNLO (COCI18_nlo)C++14
55 / 110
329 ms65540 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define INF 1000000000
#define N (int)1e6+2

using namespace std;

typedef long long ll;
typedef long double ld;

struct X{
int l;
int r;
int cost;
X (int l, int r) : l(l),r(r),cost(0){};
};

vector <vector <X> > otr;

void Upd()
{
    for (int i=0; i<otr.size(); i++)
        for (int j=0; j<otr[i].size(); j++) otr[i][j].cost++;
}

void Add(int x, int l, int r)
{
    vector <X> add;
    for (int i=0; i<otr[x].size(); i++)
        if (otr[x][i].r>=l)
    {
        if (otr[x][i].l<l) add.pb(*(new X(otr[x][i].l,l-1))),add.back().cost=otr[x][i].cost;
        add.pb(*(new X(l,r)));
        for (int j=i; j<otr[x].size(); j++)
            if (otr[x][j].r>=r)
        {
            if (otr[x][j].r>r) add.pb(*(new X(r+1,otr[x][j].r))),add.back().cost=otr[x][j].cost;
            for (int c=j+1; c<otr[x].size(); c++) add.pb(otr[x][c]);
            break;
        }
        break;
    }
    else add.pb(otr[x][i]);
    otr[x]=add;
}

int main()
{
    ios_base::sync_with_stdio(0);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    otr.resize(n);
    for (int i=0; i<n; i++) otr[i].pb(*(new X(0,m-1)));
    for (int i=0; i<k; i++)
    {
        Upd();
        int x,y,r;
        cin>>x>>y>>r;
        x--,y--;
        for (int j=0; j<=r; j++)
        {
        int kol=(int)(ld)sqrt(r*r-((r-j)*(r-j)));
        Add(x-r+j,y-kol,y+kol),Add(x+r-j,y-kol,y+kol);
        }
    }
    ll ans=0;
    /*for (int i=0; i<n; i++)
    {
        for (int j=0; j<otr[i].size(); j++) cout<<"("<<otr[i][j].l<<" "<<otr[i][j].r<<") - "<<otr[i][j].cost<<endl;
        cout<<endl;
    }*/
    for (int i=0; i<n; i++)
        for (int j=0; j<otr[i].size(); j++) ans+=(ll)(otr[i][j].r-otr[i][j].l+1)*(ll)otr[i][j].cost;
    cout<<ans;
}

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

nlo.cpp: In function 'void Upd()':
nlo.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<otr.size(); i++)
                   ~^~~~~~~~~~~
nlo.cpp:25:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=0; j<otr[i].size(); j++) otr[i][j].cost++;
                       ~^~~~~~~~~~~~~~
nlo.cpp: In function 'void Add(int, int, int)':
nlo.cpp:31:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<otr[x].size(); i++)
                   ~^~~~~~~~~~~~~~
nlo.cpp:36:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=i; j<otr[x].size(); j++)
                       ~^~~~~~~~~~~~~~
nlo.cpp:40:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int c=j+1; c<otr[x].size(); c++) add.pb(otr[x][c]);
                             ~^~~~~~~~~~~~~~
nlo.cpp: In function 'int main()':
nlo.cpp:77:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=0; j<otr[i].size(); j++) ans+=(ll)(otr[i][j].r-otr[i][j].l+1)*(ll)otr[i][j].cost;
                       ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...