제출 #1360892

#제출 시각아이디문제언어결과실행 시간메모리
1360892ddlPoi (IOI09_poi)C++20
100 / 100
126 ms31928 KiB
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define PI 3.14159265358979323846264
template<typename T>
using vec = vector<T>;
mt19937_64 rng(chrono::high_resolution_clock().now().time_since_epoch().count());
const int maxN = 2000;
int n, t, p;
int point[maxN + 5];
array<int, maxN + 5> solved[maxN + 5];
vec<tuple<int, int, int>> rank_points;
//score, solved_cnt, ID
int fpt;
bool cmp(tuple<int, int, int>& v, tuple<int, int, int>& u) {
	if (get<0>(v) == get<0>(u)) {
		if (get<1>(v) == get<1>(u)) {
			return get<2>(v) < get<2>(u);
		}
		return get<1>(v) > get<1>(u);
	}
	return get<0>(v) > get<0>(u);
}
void solve() {
	cin >> n >> t >> p;
	fill(point, point + t + 1, n);
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=t; ++j) {
			int sol;
			cin >> sol;
			solved[i][j] += sol; 
			if (sol)
				point[j]--;
		}
	}
	for (int i=1; i<=n; ++i) {
		int total = 0;
		int sol = 0;
		for (int j=1; j<=t; ++j) {
			if (solved[i][j]) total += point[j], sol++;;
		}
		rank_points.push_back({total, sol, i});
		if (i==p) fpt = total;
	}
	sort(all(rank_points), cmp);
	cout << fpt << " ";
	for (int i=0; i<sz(rank_points); ++i) {
		if (get<2>(rank_points[i]) == p) {
			cout << i+1;
			exit(0);
		} 
	}
}
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    if(fopen("TASK.in", "r")){
        freopen("TASK.in", "r", stdin);
        freopen("TASK.out", "w", stdout);
    }
    int tc = 1;
    while (tc--) {
    	solve();
    }
    cerr << "\nTime elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << ".s\n";
}

컴파일 시 표준 에러 (stderr) 메시지

poi.cpp: In function 'int32_t main()':
poi.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen("TASK.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
poi.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen("TASK.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…