Submission details
Task:3SUM
Sender:hundlij1
Submission time:2025-10-20 17:21:23 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.65 sdetails
#10ACCEPTED0.65 sdetails
#110.83 sdetails
#12ACCEPTED0.60 sdetails
#13--details
#14--details
#15--details
#16ACCEPTED0.16 sdetails
#17ACCEPTED0.15 sdetails
#18ACCEPTED0.83 sdetails
#19ACCEPTED0.65 sdetails
#20ACCEPTED0.60 sdetails
#21--details
#22--details
#23ACCEPTED0.00 sdetails

Compiler report

input/code.cpp: In function 'll maxflow(ll, ll)':
input/code.cpp:43:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   43 |     while (new_flow = bfs(s, t, parent)) {
      |            ~~~~~~~~~^~~~~~~~~~~~~~~~~~~

Code

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <climits>
#include <map>
using namespace std;
typedef long long ll;
ll n;
vector<vector<ll>> capacity;
vector<vector<ll>> adj;

ll bfs(ll s, ll t, vector<ll>& parent) {
    fill(parent.begin(), parent.end(), -1);
    parent[s] = -2;
    queue<pair<ll, ll>> q;
    q.push({s, LLONG_MAX});
    
    while (!q.empty()) {
        ll cur = q.front().first;
        ll flow = q.front().second;
        q.pop();
        
        for (ll next : adj[cur]) {
            if (parent[next] == -1 && capacity[cur][next]) {
                parent[next] = cur;
                ll new_flow = min(flow, capacity[cur][next]);
                if (next == t) return new_flow;
                q.push({next, new_flow});
            }
        }
    }
    
    return 0;
}

ll maxflow(ll s, ll t) {
    ll flow = 0;
    vector<ll> parent(n + 1);
    ll new_flow;
    
    while (new_flow = bfs(s, t, parent)) {
        flow += new_flow;
        ll cur = t;
        while (cur != s) {
            ll prev = parent[cur];
            capacity[prev][cur] -= new_flow;
            capacity[cur][prev] += new_flow;
            cur = prev;
        }
    }
    
    return flow;
}

void task1(){
    ll s, t;
    cin >> s >> t;
    vector<ll> ints(s + 1);
    vector<ll> ints2(s + 1);
    std::map<int, int> mp;

    for(ll i = 1; i <= s; i++){
        ll x;
        cin >> x;
         ints[i] = x;
        ints2[i] = x;
        mp.insert({x, i});
    } 

    vector<ll> temp;
    /*sort(ints.begin(), ints.end());
    int left = 1, right = s;
    for(int i = 1; i <= s; i++){
        while(left < right){
            ll sum = ints[left] + ints[right] + ints[i];
            if(sum == t && left != i && right != i){
                cout << left << " " << right << " " << i << endl;
                temp.push_back(ints[left]);
                temp.push_back(ints[right]);
                temp.push_back(ints[i]);

                 for(size_t i = 0; i < temp.size(); i++){
                    for(ll j = 1; j <= s; j++){
                        if(temp[i] == ints2[j]){
                            cout << j << " ";
                        }
                    }
                }
                return;
            }
            if(sum < t) left++;
            else right--;
        }
    }*/

    for(ll i = 1; i <= s; i++){
        for(ll j = i+1; j <= s; j++){
            mp.erase(ints[i]);
            mp.erase(ints[j]);
            ll need = t - ints[i] - ints[j];

            if(mp.find(need) != mp.end()){
               // cout << i << " " << j << " " << mp[need] << endl;
                temp.push_back(need);
                temp.push_back(ints[j]);
                temp.push_back(ints[i]);

                for(size_t i = 0; i < temp.size(); i++){
                    for(ll j = 1; j <= s; j++){
                        if(temp[i] == ints2[j]){
                            cout << j << " ";
                        }
                    }
                }
                return;
            }

            mp.insert({ints[i], i});
            mp.insert({ints[j], j});
        }
    }
    






   
    cout << "IMPOSSIBLE" << endl;
}

void task2(){
     ll m;
    cin >> n >> m;
    capacity.assign(n + 1, vector<ll>(n + 1, 0));
    adj.assign(n + 1, vector<ll>());
    
    for (ll i = 0; i < m; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        capacity[a][b] += c;
        adj[a].push_back(b);
    }
}


int main() {
   task1();
}

Test details

Test 1

Verdict: ACCEPTED

input
1 3
1

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 2

Verdict: ACCEPTED

input
3 5
1 3 2

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 3

Verdict: ACCEPTED

input
3 6
1 3 2

correct output
1 3 2

user output
3 2 1 

Test 4

Verdict: ACCEPTED

input
3 7
3 2 1

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 5

Verdict:

input
7 3
2 1 1 2 2 1 1

correct output
2 3 7

user output
IMPOSSIBLE

Test 6

Verdict:

input
7 4
1 1 2 2 1 2 1

correct output
1 2 6

user output
3 4 6 1 2 5 7 1 2 5 7 

Test 7

Verdict:

input
7 5
1 2 1 2 2 1 1

correct output
1 2 5

user output
1 3 6 7 2 4 5 2 4 5 

Test 8

Verdict:

input
7 6
2 1 1 1 1 2 2

correct output
1 6 7

user output
IMPOSSIBLE

Test 9

Verdict:

input
5000 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1 2 5000

user output
IMPOSSIBLE

Test 10

Verdict: ACCEPTED

input
5000 4
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 11

Verdict:

input
5000 6
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
714 3518 4240

user output
IMPOSSIBLE

Test 12

Verdict: ACCEPTED

input
5000 919900245
663612758 9075403 585385629 98...

correct output
2787 465 2266

user output
2507 2481 295 

Test 13

Verdict:

input
5000 999989608
12983 25966 38949 51932 64915 ...

correct output
IMPOSSIBLE

user output
(empty)

Test 14

Verdict:

input
5000 1000000000
65536 131072 196608 262144 327...

correct output
IMPOSSIBLE

user output
(empty)

Test 15

Verdict:

input
5000 642700000
6427 12854 19281 25708 32135 3...

correct output
IMPOSSIBLE

user output
(empty)

Test 16

Verdict: ACCEPTED

input
5000 919900246
663612758 9075403 585385629 98...

correct output
193 1698 4019

user output
3319 2564 76 

Test 17

Verdict: ACCEPTED

input
5000 919900247
663612758 9075403 585385629 98...

correct output
4258 470 1911

user output
4858 432 71 

Test 18

Verdict: ACCEPTED

input
5000 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ...

correct output
4998 4999 5000

user output
5000 4999 4998 

Test 19

Verdict: ACCEPTED

input
5000 919900247
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 20

Verdict: ACCEPTED

input
4999 919900245
9075403 585385629 987230075 83...

correct output
2786 464 2265

user output
2506 2480 294 

Test 21

Verdict:

input
5000 1000000000
261323261 25262018 237798562 3...

correct output
IMPOSSIBLE

user output
(empty)

Test 22

Verdict:

input
5000 76305003
1 5088 10175 15262 20349 25436...

correct output
IMPOSSIBLE

user output
(empty)

Test 23

Verdict: ACCEPTED

input
2 6
2 2

correct output
IMPOSSIBLE

user output
IMPOSSIBLE