답안 #886016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886016 2023-12-11T11:23:01 Z vjudge1 Curtains (NOI23_curtains) C++17
0 / 100
768 ms 720080 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
#define pb push_back
#define N 300005

const int INF = 1e9 + 7;

int32_t main(){
	fileio();
	fastio();

	int n, k;
	cin>>n>>k;
	vector<pii> todo[k + 5];
	vector<int> req(n + 5, k), arr(k + 5, 0);
	vector<vector<int>> r(n + 5, vector<int>(k + 5, 0));
	vector<vector<int>> u = r;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= k; j++){
			cin>>r[i][j];
			if (r[i][j] == 0) req[i]--;
			else todo[j].pb({r[i][j], i});
		}
	}

	for (int i = 1; i <= k; i++){
		sort(todo[i].rbegin(), todo[i].rend());
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= k; j++)
			cin>>u[i][j];
	}

	queue<int> q;
	for (int i = 1; i <= n; i++){
		if (req[i] == 0) q.push(i);
	}

	auto add = [&](int top, int val){
		arr[top] += val;
		while(!todo[top].empty() && todo[top].back().st <= arr[top]){
			int nxt = todo[top].back().nd;
			todo[top].pop_back();
			req[nxt]--;
			if (req[nxt] == 0) q.push(nxt);
		}
	};

	int ans = 0;
	while(!q.empty()){
		ans++;
		int top = q.front();
		q.pop();
		for (int i = 1; i <= k; i++)
			add(i, u[top][i]);
	}

	cout<<ans<<endl;
	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}

Compilation message

curtains.cpp: In function 'int32_t main()':
curtains.cpp:3:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:16:2: note: in expansion of macro 'fileio'
   16 |  fileio();
      |  ^~~~~~
curtains.cpp:3:59: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:16:2: note: in expansion of macro 'fileio'
   16 |  fileio();
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 768 ms 720080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 768 ms 720080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 768 ms 720080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 579 ms 719996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 768 ms 720080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 768 ms 720080 KB Output isn't correct
2 Halted 0 ms 0 KB -