답안 #1077547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077547 2024-08-27T07:58:25 Z huyngodzz Pipes (BOI13_pipes) C++14
65 / 100
107 ms 23380 KB
    ///huynhocute123///
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define pii pair<int,int>
#define piii pair<int,pair<int,int>>
#define pb push_back
#define pi M_PI
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = b; i >= a; --i)
#define ALL(v) v.begin(),v.end()
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
//random_device rd;
//mt19937 rng(rd());
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
//#define int long long
const int maxN = 1e5 + 9 ;
const int  modd = 1e9 + 7;
const int base = 2309;
const int MAX = 1e9+9;
void minimize(int &u, int v){
    if(v < u) u = v;
}
void maximize(int &u, int v){
    if(v > u) u = v;
}
int n, k, t, m, res, a[maxN], ans[maxN];
int l, r;
bool vis[maxN];
vector<pii> e[maxN];
namespace sub1{
    void dfs(int u ,int p){
        for(auto [x, id] : e[u]){
            if(x == p)continue;
            dfs(x , u);
            ans[id]= a[x];
            a[u] -= a[x];


        }
    }
    void solve(){
        dfs(1, 0);
        FOR(i, 1, m)cout << ans[i] *2 <<'\n';
    }
}
namespace sub2{
    void solve(){

    }
}
void solve(){
    cin >> n >> m;
    FOR(i, 1, n)cin >> a[i];
    FOR(i, 1, m){
        cin >> l >> r;
        e[l].pb({r, i});
        e[r].pb({l, i});
    }
    if(m > n ){
        cout << 0;
        return;
    }
    if(m == n)sub2::solve();
    else sub1::solve();

}
signed main(){
//    freopen("name.inp","r",stdin);
//    freopen("name.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    inp("task.inp");
    t = 1;
   // cin >> t;
    while( t-- )solve();

}

Compilation message

pipes.cpp: In function 'void sub1::dfs(int, int)':
pipes.cpp:37:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |         for(auto [x, id] : e[u]){
      |                  ^
pipes.cpp: In function 'int main()':
pipes.cpp:13:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
pipes.cpp:77:5: note: in expansion of macro 'inp'
   77 |     inp("task.inp");
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 3 ms 2652 KB Output is correct
4 Correct 35 ms 9264 KB Output is correct
5 Correct 2 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2652 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 31 ms 7904 KB Output is correct
14 Correct 31 ms 8796 KB Output is correct
15 Correct 32 ms 9296 KB Output is correct
16 Correct 29 ms 8188 KB Output is correct
17 Correct 35 ms 9296 KB Output is correct
18 Correct 36 ms 9456 KB Output is correct
19 Correct 39 ms 12556 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 39 ms 9296 KB Output is correct
23 Correct 28 ms 7800 KB Output is correct
24 Correct 35 ms 9296 KB Output is correct
25 Correct 29 ms 8024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2904 KB Output isn't correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Incorrect 24 ms 7756 KB Output isn't correct
4 Correct 28 ms 8028 KB Output is correct
5 Correct 26 ms 8016 KB Output is correct
6 Correct 107 ms 23380 KB Output is correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Incorrect 2 ms 2652 KB Output isn't correct
9 Incorrect 1 ms 2652 KB Output isn't correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Incorrect 1 ms 2652 KB Output isn't correct
15 Incorrect 2 ms 2720 KB Output isn't correct
16 Incorrect 1 ms 2652 KB Output isn't correct
17 Incorrect 1 ms 2652 KB Output isn't correct
18 Correct 2 ms 2664 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 1 ms 2908 KB Output is correct
22 Incorrect 1 ms 2652 KB Output isn't correct
23 Incorrect 21 ms 7000 KB Output isn't correct
24 Incorrect 33 ms 8012 KB Output isn't correct
25 Incorrect 24 ms 7764 KB Output isn't correct
26 Correct 26 ms 8020 KB Output is correct
27 Correct 27 ms 7768 KB Output is correct
28 Correct 31 ms 8244 KB Output is correct
29 Correct 83 ms 19276 KB Output is correct
30 Incorrect 24 ms 7692 KB Output isn't correct
31 Incorrect 24 ms 7764 KB Output isn't correct
32 Incorrect 35 ms 8272 KB Output isn't correct
33 Incorrect 30 ms 8028 KB Output isn't correct
34 Correct 25 ms 7824 KB Output is correct
35 Correct 26 ms 8024 KB Output is correct
36 Correct 26 ms 8168 KB Output is correct
37 Correct 105 ms 23140 KB Output is correct
38 Incorrect 25 ms 8016 KB Output isn't correct
39 Incorrect 28 ms 8364 KB Output isn't correct
40 Incorrect 30 ms 8164 KB Output isn't correct
41 Incorrect 27 ms 7772 KB Output isn't correct
42 Correct 28 ms 7760 KB Output is correct
43 Correct 27 ms 7804 KB Output is correct
44 Correct 34 ms 8052 KB Output is correct
45 Correct 97 ms 20564 KB Output is correct
46 Incorrect 27 ms 7764 KB Output isn't correct
47 Incorrect 27 ms 8152 KB Output isn't correct
48 Incorrect 25 ms 7768 KB Output isn't correct
49 Incorrect 23 ms 8028 KB Output isn't correct
50 Correct 35 ms 7988 KB Output is correct
51 Correct 28 ms 8016 KB Output is correct
52 Correct 27 ms 7712 KB Output is correct
53 Correct 87 ms 20564 KB Output is correct
54 Incorrect 26 ms 7760 KB Output isn't correct