답안 #944815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944815 2024-03-13T06:04:20 Z guagua0407 치료 계획 (JOI20_treatment) C++17
35 / 100
905 ms 524288 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

const int mxn=1e5+5;
const ll inf=1e18;
int t[mxn],l[mxn],r[mxn],c[mxn];
vector<pair<int,int>> adj[mxn];

vector<ll> dij(int n){
    vector<ll> d(n,inf);
    d[0]=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    pq.push({0,0});
    while(!pq.empty()){
        auto tmp=pq.top();
        pq.pop();
        int v=tmp.s;
        if(tmp.f!=d[v]) continue;
        for(auto u:adj[v]){
            if(d[v]+u.s<d[u.f]){
                d[u.f]=d[v]+u.s;
                pq.push({d[u.f],u.f});
            }
        }
    }
    return d;
}

int main() {_
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>t[i]>>l[i]>>r[i]>>c[i];
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=m;j++){
            if(i==j) continue;
            int x=i,y=j;
            if(t[x]<=t[y]){
                if(r[x]+t[x]>=l[y]+t[y]-1) adj[x].push_back({y,c[y]});
            }
            else{
                if(r[x]-t[x]>=l[y]-t[y]-1) adj[x].push_back({y,c[y]});
            }
        }
    }
    for(int i=1;i<=m;i++){
        if(l[i]==1) adj[0].push_back({i,c[i]});
        if(r[i]==n) adj[i].push_back({m+1,0});
    }
    vector<ll> d=dij(m+2);
    cout<<(d[m+1]==inf?-1:d[m+1])<<'\n';
    return 0;
}
//maybe its multiset not set
//yeeorz
//laborz

Compilation message

treatment.cpp: In function 'void setIO(std::string)':
treatment.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
treatment.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 905 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 3152 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 3152 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 269 ms 131776 KB Output is correct
21 Correct 226 ms 131324 KB Output is correct
22 Correct 91 ms 5712 KB Output is correct
23 Correct 86 ms 5460 KB Output is correct
24 Correct 146 ms 95648 KB Output is correct
25 Correct 123 ms 66288 KB Output is correct
26 Correct 103 ms 63316 KB Output is correct
27 Correct 135 ms 77104 KB Output is correct
28 Correct 146 ms 94912 KB Output is correct
29 Correct 108 ms 65504 KB Output is correct
30 Correct 107 ms 73564 KB Output is correct
31 Correct 116 ms 78676 KB Output is correct
32 Correct 235 ms 122944 KB Output is correct
33 Correct 305 ms 191472 KB Output is correct
34 Correct 229 ms 121992 KB Output is correct
35 Correct 228 ms 122964 KB Output is correct
36 Correct 285 ms 191316 KB Output is correct
37 Correct 229 ms 121936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 905 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -