| Task: | 3SUM |
| Sender: | hundlij1 |
| Submission time: | 2025-10-20 17:20:00 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
| #6 | ACCEPTED | 0.00 s | details |
| #7 | ACCEPTED | 0.00 s | details |
| #8 | WRONG ANSWER | 0.00 s | details |
| #9 | WRONG ANSWER | 0.68 s | details |
| #10 | ACCEPTED | 0.68 s | details |
| #11 | WRONG ANSWER | 0.85 s | details |
| #12 | ACCEPTED | 0.61 s | details |
| #13 | TIME LIMIT EXCEEDED | -- | details |
| #14 | TIME LIMIT EXCEEDED | -- | details |
| #15 | TIME LIMIT EXCEEDED | -- | details |
| #16 | ACCEPTED | 0.17 s | details |
| #17 | ACCEPTED | 0.15 s | details |
| #18 | ACCEPTED | 0.87 s | details |
| #19 | ACCEPTED | 0.68 s | details |
| #20 | ACCEPTED | 0.61 s | details |
| #21 | TIME LIMIT EXCEEDED | -- | details |
| #22 | TIME LIMIT EXCEEDED | -- | details |
| #23 | ACCEPTED | 0.00 s | details |
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 |
|---|
| 1 2 3 3 2 1 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 3 7 3 2 1 |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| IMPOSSIBLE |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 7 3 2 1 1 2 2 1 1 |
| correct output |
|---|
| 2 3 7 |
| user output |
|---|
| IMPOSSIBLE |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 7 4 1 1 2 2 1 2 1 |
| correct output |
|---|
| 1 2 6 |
| user output |
|---|
| 1 2 3 3 4 6 1 2 5 7 1 2 5 7 |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 7 5 1 2 1 2 2 1 1 |
| correct output |
|---|
| 1 2 5 |
| user output |
|---|
| 2 4 3 1 3 6 7 2 4 5 2 4 5 |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 7 6 2 1 1 1 1 2 2 |
| correct output |
|---|
| 1 6 7 |
| user output |
|---|
| IMPOSSIBLE |
Test 9
Verdict: WRONG ANSWER
| 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: WRONG ANSWER
| 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 |
|---|
| 295 2481 2507 2507 2481 295 |
Test 13
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 5000 999989608 12983 25966 38949 51932 64915 ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Test 14
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 5000 1000000000 65536 131072 196608 262144 327... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Test 15
Verdict: TIME LIMIT EXCEEDED
| 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 |
|---|
| 76 2564 3319 3319 2564 76 |
Test 17
Verdict: ACCEPTED
| input |
|---|
| 5000 919900247 663612758 9075403 585385629 98... |
| correct output |
|---|
| 4258 470 1911 |
| user output |
|---|
| 71 432 4858 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 |
|---|
| 4998 4999 5000 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 |
|---|
| 294 2480 2506 2506 2480 294 |
Test 21
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 5000 1000000000 261323261 25262018 237798562 3... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Test 22
Verdict: TIME LIMIT EXCEEDED
| 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 |
