Submission #464709

# Submission time Handle Problem Language Result Execution time Memory
464709 2021-08-13T19:35:20 Z myvaluska Sticks (POI11_pat) C++14
100 / 100
255 ms 21072 KB
// palindromefree.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//long long int cifra[20];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin >> k;
    vector<vector<int>>v(k);
    vector<pair<int, int>>vsetko;
    for(int farba=0;farba<k;farba++)
    {
        int n;
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            int dlzka;
            cin >> dlzka;
            v[farba].push_back(dlzka);
            vsetko.push_back({ dlzka,farba });
        }
    }
    sort(vsetko.begin(), vsetko.end());
    for (int i = 0; i < k; i++)
    {
        vector<pair<int,int>>kan;
        for (int j = 0; j < vsetko.size(); j++)
        {
            if (vsetko[j].second == i)
            {
                if (kan.size() >= 2)
                {
                    if (vsetko[j].first < kan[kan.size() - 1].first + kan[kan.size() - 2].first)//Platny trojuholnik!!!!
                    {
                        cout << vsetko[j].second+1 << ' ';
                        cout << vsetko[j].first << ' ';
                        cout << kan[kan.size() - 1].second+1 << ' ';
                        cout << kan[kan.size() - 1].first << ' ';
                        cout << kan[kan.size() - 2].second+1 << ' ';
                        cout << kan[kan.size() - 2].first << endl;
                        return 0;
                    }
                    
                }
            }
            else
            {
                if (kan.size() > 0)
                {
                    while (kan[kan.size() - 1].second == vsetko[j].second&&kan.size()>0)
                    {
                        kan.pop_back();
                        //cout << kan.size() << endl;
                        if (kan.size() == 0)
                        {
                            break;
                        }
                    }
                }

                    kan.push_back({ vsetko[j].first,vsetko[j].second });
            }
       }
    }
    cout << "NIE" << endl;
    return 0;
    //std::cout << "Hello World!\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

Compilation message

pat.cpp: In function 'int main()':
pat.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int j = 0; j < vsetko.size(); j++)
      |                         ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Oczekiwano NIE
2 Correct 8 ms 1056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Oczekiwano NIE
2 Correct 11 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Oczekiwano NIE
2 Correct 26 ms 2448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 900 KB Oczekiwano NIE
2 Correct 35 ms 4276 KB Output is correct
3 Correct 34 ms 2756 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2244 KB Oczekiwano NIE
2 Correct 60 ms 7824 KB Output is correct
3 Correct 55 ms 4288 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 124 ms 11584 KB Output is correct
2 Correct 88 ms 7988 KB Output is correct
3 Correct 88 ms 6140 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 138 ms 11168 KB Output is correct
2 Correct 90 ms 8244 KB Output is correct
3 Correct 115 ms 8176 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 244 ms 21072 KB Output is correct
2 Correct 130 ms 9224 KB Output is correct
3 Correct 150 ms 11288 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 255 ms 21004 KB Output is correct
2 Correct 108 ms 10280 KB Output is correct
3 Correct 201 ms 15920 KB Oczekiwano NIE