Submission #672972

# Submission time Handle Problem Language Result Execution time Memory
672972 2022-12-19T08:30:38 Z Cutebol Trading (IZhO13_trading) C++17
0 / 100
1 ms 276 KB
#include <bits/stdc++.h>
 
using namespace std;
 
void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
#define Scaramouche ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
#define int long long
#define itn int
#define endl "\n"
#define ff first
#define ss second
   
const int N = 2e5 + 5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e12 ;

int n , m ;
set < pair <int , int> , greater<pair <int , int> > > cur ;
vector <pair <int , pair <int , int> > >st ;
vector <int> ans ;

void solve(){
	
	cin >> n >> m ;
	
	for ( int i = 0 ; i < m ; i ++ ){
		int x , y , v ;
		cin >> x >> y >> v ;
		st.push_back({x,{v,y}}) ;
	}
	sort ( st.begin() , st.end() ) ;
	int ind = 0 ;
	cur.insert({0,inf}) ;
	for ( int i = 1 ; i <= n ; i ++ ){
		while ( ind < m && st[ind].ff == i ){
			cur.insert({st[ind].ss.ff,st[ind].ss.ss}) ;
			ind ++ ;
		}
		pair <int , int> t = *cur.begin() ;
		ans.push_back(t.ff) ;
		cur.erase(cur.begin()) ;
		if ( t.ff != 0 ) t.ff ++ ;
		cur.insert(t) ;
		while ( t.ss <= i ){
			cur.erase(cur.begin()) ;
			t = *cur.begin() ;
		}
	}
	for ( auto i : ans ) cout << i << ' ' ;
}
 
signed main(){
//  fopn("blocks") ;
//    Scaramouche ;
    int t = 1 ;
//      cin >> t ;
    while ( t -- ) solve() ; 
}

Compilation message

trading.cpp: In function 'void fopn(std::string)':
trading.cpp:5:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trading.cpp:5:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 276 KB Output isn't correct
4 Halted 0 ms 0 KB -