提出 #39671462


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=800005;
inline int read() {
    static int x=0,c=getchar(),f=1;
    for(f=1; c<=47||c>=58; c=getchar()) f=f&&(c^45);
    for(x=0; c>=48&&c<=57; c=getchar()) x=(x<<3)+(x<<1)+(c&15);
    return f?x:-x;
}
ll a,b,c;
inline void solve() {
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a>b)swap(a,b);
	if(a>c)swap(a,c);
	if(b>c)swap(b,c);
	if((a+b+c)%3||(a^b)&1||(b^c)&1) {
		printf("-1\n");
	} else {
		ll x=(b-a+c-a)/3+a;
		if((x^a)&1) printf("-1\n");
		else printf("%lld\n",abs(x-a)+abs(x-b)+abs(x-c)>>2);
	}
}
int main() {
    int t;
    scanf("%d",&t);
    while(t--)solve();
    return 0;
}

提出情報

提出日時
問題 A - +3 +5 +7
ユーザ mod998244353
言語 C++ (GCC 9.2.1)
得点 300
コード長 692 Byte
結果 AC
実行時間 85 ms
メモリ 3740 KiB

コンパイルエラー

./Main.cpp: In function ‘void solve()’:
./Main.cpp:22:41: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   22 |   else printf("%lld\n",abs(x-a)+abs(x-b)+abs(x-c)>>2);
      |                        ~~~~~~~~~~~~~~~~~^~~~~~~~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   27 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
./Main.cpp: In function ‘void solve()’:
./Main.cpp:13:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%lld%lld%lld",&a,&b,&c);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 7
セット名 テストケース
Sample 01_sample_01.txt
All 01_sample_01.txt, 02_test_a_01.txt, 02_test_a_02.txt, 03_test_b_01.txt, 03_test_b_02.txt, 04_test_c_01.txt, 04_test_c_02.txt
ケース名 結果 実行時間 メモリ
01_sample_01.txt AC 5 ms 3560 KiB
02_test_a_01.txt AC 80 ms 3556 KiB
02_test_a_02.txt AC 80 ms 3604 KiB
03_test_b_01.txt AC 72 ms 3676 KiB
03_test_b_02.txt AC 72 ms 3640 KiB
04_test_c_01.txt AC 84 ms 3740 KiB
04_test_c_02.txt AC 85 ms 3604 KiB