제출 #335317

#제출 시각아이디문제언어결과실행 시간메모리
335317gmyuEditor (BOI15_edi)C++14
15 / 100
851 ms30828 KiB
/* ID: USACO_template LANG: C++ PROG: USACO */ #include <iostream> //cin , cout #include <fstream> //fin, fout #include <stdio.h> // scanf , pringf #include <cstdio> #include <algorithm> // sort , stuff #include <stack> // stacks #include <queue> // queues #include <map> #include <string> using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; /// adjlist without weight typedef vector<pii> vii; /// adjlist with weight typedef vector<pair<int,pii>> vpip; /// edge with weight typedef long long ll; #define mp make_pair #define fst first #define snd second #define pb push_back #define sz(x) (int)(x).size() #define trav(u, adj_v) for (auto& u: adj_v) const int MOD = 1e9+7; // 998244353; const int MX = 2e5+5; // const ll INF = 1e18; // #define MAXV 300007 #define MAXE 100007 const int xdir[4] = {1,0,-1,0}, ydir[4] = {0,1,0,-1}; /// 4 directions struct NODE { int x, y; int val; int visited; bool operator< (NODE b) const { return (x == b.x) ? (y < b.y) : (x < b.x); } }; struct EDGE { int from, to; ll weight; bool operator<(EDGE other) const { return weight < other.weight; } }; /// code from USACO examples void setIO(string name) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } bool debug = false, submit = true; int N; int a[MAXV], lev[MAXV], state[MAXV]; #define MAXLCALOG 20 int anc[MAXV][MAXLCALOG]; int getP(int curr, int wantedDepth) { /// reach wanted depth for(int k = MAXLCALOG - 1; k>= 0; k--) { while(anc[curr][k] > wantedDepth) { curr = anc[curr][k]; } } return curr; } int main() { debug = true; submit = false; if(submit) setIO("Editor"); int i, j, k; cin >> N ; for(i=1; i <= N; i++) { cin >> a[i]; if(a[i] > 0) { lev[i] = 0; state[i] = a[i]; cout << a[i] << endl; } else { lev[i] = -a[i]; j = getP(i - 1, lev[i] - 1); k = getP(j - 1, lev[i] - 1); anc[i][0] = k; for(j = 1; j < MAXLCALOG; j++) anc[i][j] = anc[anc[i][j-1]][j-1]; k = getP(i, 0); cout << state[k] << endl; } } }

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

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