Submission #313919

# Submission time Handle Problem Language Result Execution time Memory
313919 2020-10-17T09:59:47 Z hoaphat1 Sticks (POI11_pat) C++17
100 / 100
202 ms 4260 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(2,make_pair(0,0));
			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) {
					if (a[j][id[j]] >= b[0].first) {
						b[1] = b[0];
						b[0] = make_pair(a[j][id[j]],j);
					}
					else if (a[j][id[j]] > b[1].first) {
						b[1] = make_pair(a[j][id[j]],j);
					}
				}
			}
			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 0 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 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Oczekiwano NIE
2 Correct 10 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Oczekiwano NIE
2 Correct 18 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 640 KB Oczekiwano NIE
2 Correct 29 ms 888 KB Output is correct
3 Correct 26 ms 768 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 18 ms 640 KB Oczekiwano NIE
2 Correct 48 ms 1400 KB Output is correct
3 Correct 40 ms 888 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 100 ms 2300 KB Output is correct
2 Correct 65 ms 1656 KB Output is correct
3 Correct 68 ms 1272 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 94 ms 2364 KB Output is correct
2 Correct 71 ms 1784 KB Output is correct
3 Correct 80 ms 1528 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 196 ms 4220 KB Output is correct
2 Correct 98 ms 1912 KB Output is correct
3 Correct 116 ms 2040 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 202 ms 4260 KB Output is correct
2 Correct 86 ms 2180 KB Output is correct
3 Correct 142 ms 2428 KB Oczekiwano NIE