提出 #70137997


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,C[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>C[i];
	FOR(i,N) {
		int ret=0;
		FOR(j,N) if(C[i]==C[j]) ret+=abs(i-j);
		cout<<ret<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

提出情報

提出日時
問題 D - 距離 (Distance)
ユーザ kmjp
言語 C++ 20 (gcc 12.2)
得点 100
コード長 1022 Byte
結果 AC
実行時間 1 ms
メモリ 3608 KiB

コンパイルエラー

Main.cpp: In function ‘void solve()’:
Main.cpp:19:17: warning: unused variable ‘k’ [-Wunused-variable]
   19 |         int i,j,k,l,r,x,y; string s;
      |                 ^
Main.cpp:19:19: warning: unused variable ‘l’ [-Wunused-variable]
   19 |         int i,j,k,l,r,x,y; string s;
      |                   ^
Main.cpp:19:21: warning: unused variable ‘r’ [-Wunused-variable]
   19 |         int i,j,k,l,r,x,y; string s;
      |                     ^
Main.cpp:19:23: warning: unused variable ‘x’ [-Wunused-variable]
   19 |         int i,j,k,l,r,x,y; string s;
      |                       ^
Main.cpp:19:25: warning: unused variable ‘y’ [-Wunused-variable]
   19 |         int i,j,k,l,r,x,y; string s;
      |                         ^
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:6:19: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                   ^~~
Main.cpp:35:9: note: in expansion of macro ‘FOR’
   35 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |         ^~~
Main.cpp:6:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                   ^~~
Main.cpp:35:45: note: in expansion of macro ‘FOR’
   35 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                             ^~~
Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
Main.cpp:35:45: note: in expansion of macro ‘FOR’
   35 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                             ^~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 100 / 100
結果
AC × 4
AC × 19
セット名 テストケース
Sample sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
ケース名 結果 実行時間 メモリ
01-01.txt AC 1 ms 3372 KiB
01-02.txt AC 1 ms 3372 KiB
01-03.txt AC 1 ms 3372 KiB
01-04.txt AC 1 ms 3604 KiB
01-05.txt AC 1 ms 3500 KiB
01-06.txt AC 1 ms 3324 KiB
01-07.txt AC 1 ms 3476 KiB
01-08.txt AC 1 ms 3396 KiB
01-09.txt AC 1 ms 3392 KiB
01-10.txt AC 1 ms 3420 KiB
01-11.txt AC 1 ms 3604 KiB
01-12.txt AC 1 ms 3608 KiB
01-13.txt AC 1 ms 3348 KiB
01-14.txt AC 1 ms 3476 KiB
01-15.txt AC 1 ms 3460 KiB
sample-01.txt AC 1 ms 3436 KiB
sample-02.txt AC 1 ms 3516 KiB
sample-03.txt AC 1 ms 3460 KiB
sample-04.txt AC 1 ms 3476 KiB