제출 #1222079

#제출 시각아이디문제언어결과실행 시간메모리
1222079kp8769159976Tracks in the Snow (BOI13_tracks)C++20
0 / 100
1213 ms1114112 KiB
#include <bits/stdc++.h> // #include <ctime> // for clock() and CLOCKS_PER_SEC // #include <sys/resource.h> // #include <iostream> // #include <cstdlib> // void capMemory(size_t M_bytes) { // struct rlimit rl; // // RLIMIT_AS caps total address space (stack + heap + code) // rl.rlim_cur = M_bytes; // rl.rlim_max = M_bytes; // if (setrlimit(RLIMIT_AS, &rl) != 0) { // perror("setrlimit"); // std::exit(1); // } // } using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef pair<int, int> pip; typedef pair<ll, ll> plip; typedef vector<int> vi; typedef vector<float> vf; typedef vector<ll> vli; typedef vector<vi> vvi; typedef vector<vf> vvf; typedef vector<vli> vvli; typedef vector<pip> vpip; typedef unordered_set<ll> usi; typedef set<ll> si; typedef priority_queue<ll> pq; typedef unordered_map<ll, ll> umpi; typedef map<ll, ll> mpi; const int MOD = 1000000007; const int MOD1 = 998244353; #define For(i, a, b) \ for (int i = (a), __end = (b), __dir = ((a) < (b) ? 1 : -1); \ (__dir > 0 ? i < __end : i > __end); \ i += __dir) #define Rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) (v).begin(), (v).end() #define Be(v) (v).begin() #define Ee(v) (v).end() #define Pb push_back #define Mp make_pair #define Sz(v) ((int)(v).size()) #define F first #define S second #define pc(v) cout << v ; #define pr(v) cout << v << " "; #define pe(v) cout << v << endl; using ll = long long; using vi = vector<int>; #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() using pi = pair<int, int>; #define f first #define s second #define mp make_pair const vpip dir = { {1, 0} , { 0 , 1} , {-1 , 0 } , { 0 , -1}}; void in(int &x) { cin >> x; } void in(long long &x) { cin >> x; } void in(char &x) { cin >> x; } template<typename T> void in( vector<T> &v) { for (auto &t : v) in(t); } void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io cout.tie(0)->sync_with_stdio(0); // see /general/fast-io if (sz(name)) { freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output freopen((name + ".out").c_str(), "w", stdout); } } // jai sia ram auto comp (const plip & a , const plip & b ) { return tie(a.F , a.S) < tie(b.F , b.S); } auto compgreater (const plip & a , const plip & b ) { return tie(a.F , a.S) > tie(b.F , b.S); } ll mod_exp(ll b, ll exp, ll mod) { ll result = 1; while (exp > 0) { if (exp % 2 == 1) { result = (result * b) % mod; } b = (b * b) % mod; exp /= 2; } return result; } ll mod_inverse(ll a, ll mod) { return mod_exp(a, mod - 2, mod); } void f() { ll n , s, x; cin >> n>> s >>x; vli a(n); for( int i = 0 ; i < n;i++)cin >>a[i]; if( n == 1){ if (a[0] == s && a[0] == x){ cout <<1 <<endl; } else cout <<0 <<endl; return; } ll l = 0 , r = 0 ; multiset<ll> st; ll sum = 0; ll cnt = 0; while( r < n ){ cout << "srs"<<endl; while (sum < s && r < n) { sum += a[r]; st.insert(a[r]); r++; } if ( sum == s && !st.empty() && *st.rbegin() == x )cnt++; if ( sum >= s ){ auto tt = st.find(a[l]); st.erase(tt); sum -= a[l]; l++; } if ( r == n){ if ( sum == s && !st.empty() && *st.rbegin() == x )cnt++; } } cout << r <<endl; } void g() { ll n ; cin >> n ; vli a( n ); ll prev0 = 0; ll prev1 = 0; ll sum = 0; for( int i = 0 ; i < n;i++){ char cc; cin >>cc; int c = cc -'0'; if( c == 0 ){ a[i] = (( i + 1) * ( i +2 ))/2 - prev1 ; prev0 = a[i]; } else{ a[i] = (( i + 1) * ( i +2 ))/2 - prev0 ; prev1 = a[i]; } sum += a[i]; } cout << sum <<endl; } int n , m; void dfs(int i , int j, int compno , vvi & vis , vvi & a) { vis [ i ][ j ] = compno; for( auto &c : dir){ int x = i + c.first; int y = j + c.second; if ( x >=0 && y >= 0 && x < n && y < m){ if ( a[ x ][ y]!=0 && vis[x][y]==0 )dfs(x , y , compno , vis , a); } } } void tracks( ) { cin >>n >> m; vvi a( n ,vi ( m )) ; for( int i = 0 ; i < n;i++){ string g; cin >> g; for( int j = 0 ; j < m ; j++){ if ( g[ j ] == 'F')a[i][j] = 1; // F else if ( g[ j ] == 'R') a[ i ][ j ] = 2; //R } } vvi vis( n , vi( m )); int compno = 1; for( int i =0 ; i < n ;i++){ for( int j = 0 ; j < m ; j++){ if ( a[ i ][ j ]!=0 && vis[i][j]==0 ) dfs( i , j ,compno , vis ,a ); compno++; } } set < pair < int , int >> st; for( int i = 0 ; i < n ;i++ ){ for( int j = 0 ; j < m ;j++){ if (a[i][j]!=0&& vis[i][j]!=0){ st.insert({a[i][j],vis[i][j]}); } } } cout << st.size() <<endl; } int main () { // setIO(""); tracks(); }

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

tracks.cpp: In function 'void setIO(std::string)':
tracks.cpp:89:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |                 freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:90:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |                 freopen((name + ".out").c_str(), "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...