답안 #810343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810343 2023-08-06T08:40:19 Z vjudge1 Worst Reporter 4 (JOI21_worst_reporter4) C++14
0 / 100
3 ms 2060 KB

#include <bits/stdc++.h>



using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 5e3 + 9 , mod = 1e9 + 7;
ll  d[N] = {} , a[N] = {}, b[N] , c[N] , us[N] = {} , p[N] = {};
vector<ll>v[N] , v1[N];
map<int,ll>mp[N];
void solve(){
    ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
    cin>>n;
    vector<ll>vc;
    for(i = 1; i <= n; i++){
        cin>>a[i]>>b[i]>>c[i];
        if(i != 1)
            v[a[i]].pb(i);
        vc.pb(b[i]);
    }
    sort(rall(vc));
    for(i = n; i >= 1; i--){
        if(v[i].size() == 0){
            for(auto to : vc)
                if(to == b[i])
                    mp[i][to] = 0;
                else
                    mp[i][to] = c[i];
            continue;
        }
        for(auto to : v[i])
            d[to] = 1e14;
        for(auto it : vc){
            s = 0;
            for(auto to : v[i])
                d[to] = min(d[to] , mp[to][it]) ,s += d[to];
            if(it == b[i])
                mp[i][it] = s ;
            else
                mp[i][it] = c[i] + s;
        if(i == 1 && mp[i][it] < mn)
            mn = mp[i][it];
        }
    }
    cout<<mn<<"\n";
}

int main(){

     TL;
     #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
     #endif

int t = 1;
//cin>>t;

while(t--)
     {
     solve();
     }

}
// Author : حسن

Compilation message

worst_reporter2.cpp: In function 'void solve()':
worst_reporter2.cpp:30:8: warning: unused variable 'q' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |        ^
worst_reporter2.cpp:30:16: warning: unused variable 'j' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                ^
worst_reporter2.cpp:30:20: warning: unused variable 'm' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                    ^
worst_reporter2.cpp:30:26: warning: unused variable 'z' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                          ^
worst_reporter2.cpp:30:37: warning: unused variable 'f' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                     ^
worst_reporter2.cpp:30:41: warning: unused variable 'l' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                         ^
worst_reporter2.cpp:30:45: warning: unused variable 'r' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                             ^
worst_reporter2.cpp:30:49: warning: unused variable 'k' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                 ^
worst_reporter2.cpp:30:53: warning: unused variable 'x' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                     ^
worst_reporter2.cpp:30:57: warning: unused variable 'y' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                         ^
worst_reporter2.cpp:30:74: warning: unused variable 'mx' [-Wunused-variable]
   30 |     ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                                          ^~
worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:70:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |      freopen("input.txt", "r", stdin);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
worst_reporter2.cpp:71:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |      freopen("output.txt", "w", stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2060 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2060 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2060 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -