답안 #850389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850389 2023-09-16T13:38:50 Z AliHasanli 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
using namespace std;
map<int,int>mX,mY;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
{
    for(int i=0;i<X.size();i++)
    {
        mX[X[i]]=1;
        mY[Y[i]]=1;
    }
    if(N==1)
        return 0;
    bool check=true;
    int maxX=0;
    for(int i:X)
        maxX=max(maxX,i);
    for(int i:X)
        if(i%2)
        {
            check=false;
            break;
        }
    long long ans=0;
    if(check)
    {
        for(int i=0;i<W.size();i++)
        ans+=W[i];
        return ans;
    }
    if(maxX==0)
    {
        for(int i=0;i<W.size();i++)
            ans+=W[i];
        return ans;
    }
    if(maxX==1)
    {
        long long ansX0=0,ansX1=0;
        for(int i=0;i<X.size();i++)
            if(X[i]==1)
                ansX1+=W[i];
        ans=anxX1;
        for(int i=0;i<N;i++)
        {
            if(mY[i]==1 && mX[1]==1)
            anxX1-=W[i];
            if(mY[i]==1 && mX[0]==1)
        }
        return max(ansX0,ansX1);
    }
    return 0;
}
int main() {
  int N, M;
  cin>>N>>M;
  vector<int> X(M), Y(M), W(M);
  for (int i = 0; i < M; ++i)
    cin>>X[i]>>Y[i]>>W[i];
  long long result = max_weights(N, M, X, Y, W);
  cout<<result;
  return 0;
}

Compilation message

fish.cpp:4:1: error: 'map' does not name a type
    4 | map<int,int>mX,mY;
      | ^~~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0;i<X.size();i++)
      |                 ~^~~~~~~~~
fish.cpp:9:9: error: 'mX' was not declared in this scope; did you mean 'X'?
    9 |         mX[X[i]]=1;
      |         ^~
      |         X
fish.cpp:10:9: error: 'mY' was not declared in this scope; did you mean 'Y'?
   10 |         mY[Y[i]]=1;
      |         ^~
      |         Y
fish.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(int i=0;i<W.size();i++)
      |                     ~^~~~~~~~~
fish.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i=0;i<W.size();i++)
      |                     ~^~~~~~~~~
fish.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i=0;i<X.size();i++)
      |                     ~^~~~~~~~~
fish.cpp:43:13: error: 'anxX1' was not declared in this scope; did you mean 'ansX1'?
   43 |         ans=anxX1;
      |             ^~~~~
      |             ansX1
fish.cpp:46:16: error: 'mY' was not declared in this scope; did you mean 'Y'?
   46 |             if(mY[i]==1 && mX[1]==1)
      |                ^~
      |                Y
fish.cpp:46:28: error: 'mX' was not declared in this scope; did you mean 'X'?
   46 |             if(mY[i]==1 && mX[1]==1)
      |                            ^~
      |                            X
fish.cpp:48:16: error: 'mY' was not declared in this scope; did you mean 'Y'?
   48 |             if(mY[i]==1 && mX[0]==1)
      |                ^~
      |                Y
fish.cpp:48:28: error: 'mX' was not declared in this scope; did you mean 'X'?
   48 |             if(mY[i]==1 && mX[0]==1)
      |                            ^~
      |                            X
fish.cpp:49:9: error: expected primary-expression before '}' token
   49 |         }
      |         ^