Submission #313916

# Submission time Handle Problem Language Result Execution time Memory
313916 2020-10-17T09:56:45 Z hoaphat1 Sticks (POI11_pat) C++17
100 / 100
207 ms 13944 KB
#include<bits/stdc++.h>
 
using namespace std;

void fff(string s = "") {
	if (s == "1") cin >> s;
	if ((int)s.size() >= 4 && s.substr(s.size() - 4) == ".inp") {
		freopen(s.c_str(),"r",stdin);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	fff("");
	int n;
	cin >> n;
	vector<vector<int>> a(n);
	for (int i = 0; i < n; i++) {
		int foo;
		cin >> foo;
		a[i].resize(foo);
		for (auto&x : a[i]) {
			cin >> x;
		}
		sort(a[i].begin(),a[i].end());
	}
	for (int i = 0; i < n; i++) {
		vector<int> id(n,-1);
		for (auto&x : a[i]) {
			vector<pair<int,int>> b;
			for (int j = 0; j < n; j++) {
				if (i == j) continue;
				while (id[j] < (int)a[j].size() - 1 && a[j][id[j] + 1] <= x) id[j] += 1;
				if (id[j] != -1) b.emplace_back(a[j][id[j]],j);
				if ((int)b.size() > 2) {
					sort(b.rbegin(),b.rend());
					b.pop_back();
				}
			}
			if ((int)b.size() == 2 && b[0].first + b[1].first > x) {
				cout << i + 1 <<" " << x <<" " << b[0].second + 1 <<" " << b[0].first <<" " << b[1].second + 1 <<" " << b[1].first;
				exit(0);
			}
		}
	}
	cout << "NIE";
} 

Compilation message

pat.cpp: In function 'void fff(std::string)':
pat.cpp:8:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    8 |   freopen(s.c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Oczekiwano NIE
2 Correct 7 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Oczekiwano NIE
2 Correct 12 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Oczekiwano NIE
2 Correct 18 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 640 KB Oczekiwano NIE
2 Correct 28 ms 2176 KB Output is correct
3 Correct 42 ms 1536 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1152 KB Oczekiwano NIE
2 Correct 48 ms 3672 KB Output is correct
3 Correct 56 ms 2168 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 102 ms 7112 KB Output is correct
2 Correct 79 ms 4348 KB Output is correct
3 Correct 76 ms 3192 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 98 ms 7160 KB Output is correct
2 Correct 89 ms 4900 KB Output is correct
3 Correct 115 ms 3960 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 207 ms 13944 KB Output is correct
2 Correct 145 ms 5752 KB Output is correct
3 Correct 145 ms 5752 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 196 ms 13944 KB Output is correct
2 Correct 86 ms 6392 KB Output is correct
3 Correct 181 ms 6780 KB Oczekiwano NIE