제출 #657435

#제출 시각아이디문제언어결과실행 시간메모리
657435PanTkd로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include <stdio.h> #include <stdlib.h> #include "robots.h" #include <iostream> #define fail(s, x...) do { \ fprintf(stderr, s "\n", ## x); \ exit(1); \ } while(0) #define MAX_A 50000 #define MAX_B 50000 #define MAX_T 500000 static int X[MAX_A]; static int Y[MAX_B]; static int W[MAX_T]; static int S[MAX_T]; int main() { int A, B, T, i; int res; FILE *f = fopen("robots.in", "r"); if (!f) fail("Failed to open input file."); res = fscanf(f, "%d", &A); if (res != 1) fail("Failed to read A from input file."); if (A < 0 || A > MAX_A) fail("A is out of bounds."); res = fscanf(f, "%d", &B); if (res != 1) fail("Failed to read B from input file."); if (B < 0 || B > MAX_B) fail("B is out of bounds."); res = fscanf(f, "%d", &T); if (res != 1) fail("Failed to read T from input file."); if (T < 1 || T > MAX_T) fail("T is out of bounds."); for (i = 0; i < A; i++) { res = fscanf(f, "%d", &X[i]); if (res != 1) fail("Failed to read data from input file."); } for (i = 0; i < B; i++) { res = fscanf(f, "%d", &Y[i]); if (res != 1) fail("Failed to read data from input file."); } for (i = 0; i < T; i++) { res = fscanf(f, "%d%d", &W[i], &S[i]); if (res != 2) fail("Failed to read data from input file."); } fclose(f); int answer = putaway(A, B, T, X, Y, W, S); printf("%d\n", answer); return 0; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { ll ans=-1; if(A==2){ ll x1=max(X[0],X[1]),x2=min(X[0],X[1]); ll w1=max(W[0],W[1]),w2=min(W[0],W[1]); if(x1>w1&&x2>w2) ans=1; else if(x1>w1) ans = 2; } else if(A==1&&B==1){ for(ll i = 0 ;i<2;i++){ if(X[0]>W[i%2] && X[0]>W[(i+1)%2])ans=2; else if(Y[0]>S[i%2] && Y[0]>S[(i+1)%2])ans=2; } for(ll i = 0 ;i<2;i++){ if(X[0]>W[i%2] && Y[0]>S[(i+1)%2])ans=1; } } else{ ll y1=max(Y[0],Y[1]),y2=min(Y[0],Y[1]); ll s1=max(S[0],S[1]),s2=min(S[0],S[1]); if(y1>s1&&y2>s2) ans=1; else if(y1>s1) ans = 2; } cout<<ans<<endl; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:72:5: error: 'll' was not declared in this scope
   72 |     ll ans=-1;
      |     ^~
robots.cpp:74:11: error: expected ';' before 'x1'
   74 |         ll x1=max(X[0],X[1]),x2=min(X[0],X[1]);
      |           ^~~
      |           ;
robots.cpp:75:11: error: expected ';' before 'w1'
   75 |         ll w1=max(W[0],W[1]),w2=min(W[0],W[1]);
      |           ^~~
      |           ;
robots.cpp:76:12: error: 'x1' was not declared in this scope
   76 |         if(x1>w1&&x2>w2) ans=1;
      |            ^~
robots.cpp:76:15: error: 'w1' was not declared in this scope
   76 |         if(x1>w1&&x2>w2) ans=1;
      |               ^~
robots.cpp:76:19: error: 'x2' was not declared in this scope
   76 |         if(x1>w1&&x2>w2) ans=1;
      |                   ^~
robots.cpp:76:22: error: 'w2' was not declared in this scope
   76 |         if(x1>w1&&x2>w2) ans=1;
      |                      ^~
robots.cpp:76:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   76 |         if(x1>w1&&x2>w2) ans=1;
      |                          ^~~
      |                          abs
robots.cpp:77:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
   77 |         else if(x1>w1) ans = 2;
      |                        ^~~
      |                        abs
robots.cpp:80:15: error: expected ';' before 'i'
   80 |         for(ll i = 0 ;i<2;i++){
      |               ^~
      |               ;
robots.cpp:80:23: error: 'i' was not declared in this scope
   80 |         for(ll i = 0 ;i<2;i++){
      |                       ^
robots.cpp:81:47: error: 'ans' was not declared in this scope; did you mean 'abs'?
   81 |             if(X[0]>W[i%2] && X[0]>W[(i+1)%2])ans=2;
      |                                               ^~~
      |                                               abs
robots.cpp:82:52: error: 'ans' was not declared in this scope; did you mean 'abs'?
   82 |             else if(Y[0]>S[i%2] && Y[0]>S[(i+1)%2])ans=2;
      |                                                    ^~~
      |                                                    abs
robots.cpp:84:15: error: expected ';' before 'i'
   84 |         for(ll i = 0 ;i<2;i++){
      |               ^~
      |               ;
robots.cpp:84:23: error: 'i' was not declared in this scope
   84 |         for(ll i = 0 ;i<2;i++){
      |                       ^
robots.cpp:85:47: error: 'ans' was not declared in this scope; did you mean 'abs'?
   85 |             if(X[0]>W[i%2] && Y[0]>S[(i+1)%2])ans=1;
      |                                               ^~~
      |                                               abs
robots.cpp:89:11: error: expected ';' before 'y1'
   89 |         ll y1=max(Y[0],Y[1]),y2=min(Y[0],Y[1]);
      |           ^~~
      |           ;
robots.cpp:90:11: error: expected ';' before 's1'
   90 |         ll s1=max(S[0],S[1]),s2=min(S[0],S[1]);
      |           ^~~
      |           ;
robots.cpp:91:12: error: 'y1' was not declared in this scope
   91 |         if(y1>s1&&y2>s2) ans=1;
      |            ^~
robots.cpp:91:15: error: 's1' was not declared in this scope
   91 |         if(y1>s1&&y2>s2) ans=1;
      |               ^~
robots.cpp:91:19: error: 'y2' was not declared in this scope
   91 |         if(y1>s1&&y2>s2) ans=1;
      |                   ^~
robots.cpp:91:22: error: 's2' was not declared in this scope
   91 |         if(y1>s1&&y2>s2) ans=1;
      |                      ^~
robots.cpp:91:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   91 |         if(y1>s1&&y2>s2) ans=1;
      |                          ^~~
      |                          abs
robots.cpp:92:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
   92 |         else if(y1>s1) ans = 2;
      |                        ^~~
      |                        abs
robots.cpp:94:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   94 |     cout<<ans<<endl;
      |     ^~~~
      |     std::cout
In file included from robots.cpp:4:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
robots.cpp:94:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   94 |     cout<<ans<<endl;
      |           ^~~
      |           abs
robots.cpp:94:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   94 |     cout<<ans<<endl;
      |                ^~~~
      |                std::endl
In file included from /usr/include/c++/10/iostream:39,
                 from robots.cpp:4:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
robots.cpp:95:1: warning: no return statement in function returning non-void [-Wreturn-type]
   95 | }
      | ^