Submission #26971

#TimeUsernameProblemLanguageResultExecution timeMemory
26971repeating코끼리 (Dancing Elephants) (IOI11_elephants)C++11
26 / 100
9000 ms20800 KiB
#include <bits/stdc++.h> #include "elephants.h" #define F first #define S second #define P push #define pb push_back #define MEM(dp,i) memset(dp,i,sizeof(dp)) #define W while #define R return #define C continue #define SI size() #define ll long long #define ld long double #define pll pair<ll,ll> #define pii pair<int,int> #define SF(x) scanf("%I64d",&x) #define SF2(x,y) scanf("%I64d%I64d",&x,&y) #define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z) #define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o) #define all(v) v.begin(),v.end() #define MAX_R 1000000 #define MAX_N 1000000 #define MAX_M 1000000 using namespace std; const long long INF = 1e9+5e8; const int MX=109; int n; vector<pii> v; int l; void init(int N, int L, int X[]) { l=L; n = N; for(int i=0;i<n;i++) v.pb({X[i],i}); } int update(int x, int y) { int ind; for(int i=0;i<v.SI;i++){ if(v[i].S==x)ind=i; } v[ind].F=y; W(1){ if((ind==0||v[ind-1].F<=v[ind].F)&&(ind==n-1||v[ind].F<=v[ind+1].F))break; if(!(ind==0||v[ind-1].F<=v[ind].F)){ swap(v[ind],v[ind-1]); ind--; } else{ swap(v[ind],v[ind+1]); ind++; } } // for(auto i : v)cout<<i.F<<" "; // cout<<endl; int last=0; int ret=1; for(int i=1;i<v.SI;i++){ if(v[i].F-v[last].F>l){ ret++; last=i; } } return ret; } // //static int N,L,M; //static int X[MAX_N]; //static int ii[MAX_M]; //static int yy[MAX_M]; //static int sol[MAX_M]; // //inline //void my_assert(int e) {if (!e) abort();} // //void read_input() //{ // int i; // my_assert(3==scanf("%d %d %d",&N,&L,&M)); // for(i=0; i<N; i++) // my_assert(1==scanf("%d",&X[i])); // for(i=0; i<M; i++) // my_assert(3==scanf("%d %d %d",&ii[i],&yy[i],&sol[i])); //} // //int main() //{ // int i, ans; // // read_input(); // init(N,L,X); // for(i=0; i<M; i++) { // ans = update(ii[i],yy[i]); // if(ans==sol[i])continue; // printf("Incorrect. In %d-th move, answered %d (%d expected).\n", // i+1, ans, sol[i]); // return 0; // } // printf("Correct.\n"); // return 0; //}

Compilation message (stderr)

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:44:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v.SI;i++){
                  ^
elephants.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<v.SI;i++){
                  ^
elephants.cpp:47:10: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
     v[ind].F=y;
          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...